| Crates.io | quantum-shield |
| lib.rs | quantum-shield |
| version | 0.1.0 |
| created_at | 2025-10-24 23:20:55.251636+00 |
| updated_at | 2025-10-24 23:20:55.251636+00 |
| description | Hybrid quantum-resistant cryptography using NIST-standardized post-quantum algorithms (Kyber, Dilithium) |
| homepage | |
| repository | https://github.com/redasgard/quantum-shield |
| max_upload_size | |
| id | 1899456 |
| size | 270,254 |
Hybrid quantum-resistant cryptography library using NIST-standardized post-quantum algorithms.
Combines classical cryptography (RSA-4096) with post-quantum algorithms (Kyber-1024, Dilithium5) for defense-in-depth against both current and future quantum computer attacks.
NIST Level 5 (equivalent to AES-256 security)
Add to your Cargo.toml:
[dependencies]
quantum-shield = "0.1"
use quantum_shield::{HybridCrypto, KeyPair};
// Generate keypairs
let alice = HybridCrypto::generate_keypair()?;
let bob = HybridCrypto::generate_keypair()?;
// Alice encrypts a message for Bob
let message = b"Secret quantum-resistant message";
let encrypted = alice.encrypt(message, &bob.public_keys())?;
// Bob decrypts the message
let decrypted = bob.decrypt(&encrypted)?;
assert_eq!(message, &decrypted[..]);
use quantum_shield::HybridCrypto;
let alice = HybridCrypto::generate_keypair()?;
// Alice signs a message
let message = b"I agree to these terms";
let signature = alice.sign(message)?;
// Anyone can verify with Alice's public key
let valid = alice.verify(message, &signature, &alice.public_keys())?;
assert!(valid);
1. Generate random AES-256 key
2. Encrypt message with AES-256-GCM
3. Encrypt AES key with RSA-4096 ← Classical layer
4. Encrypt AES key with Kyber-1024 ← Post-quantum layer
5. Return: [ciphertext, enc_key_rsa, enc_key_kyber]
Decryption:
1. Try to decrypt key with RSA
2. If RSA fails, use Kyber (automatic failover)
3. Decrypt message with recovered key
Security = MAX(RSA security, Kyber security)
Defense against unknown threats:
| Operation | Time | Note |
|---|---|---|
| Key generation | ~100ms | RSA is slow, but one-time |
| Encryption | ~1-2ms | Per message |
| Decryption | ~1-2ms | Per message |
| Signing | ~0.5ms | Per message |
| Verification | ~0.3ms | Per message |
Note: Post-quantum algorithms (Kyber, Dilithium) have faster signing/verification than RSA-4096.
// Core functionality
HybridCrypto::generate_keypair() // Generate all keys
encrypt(data, recipient_pubkeys) // Hybrid encrypt
decrypt(encrypted_data) // Hybrid decrypt (auto-failover)
sign(message) // Hybrid sign
verify(message, signature, pubkeys) // Verify hybrid signature
// Key management
public_keys() // Export public keys
PublicKeys::to_json() // Serialize to JSON
PublicKeys::from_json(json) // Deserialize from JSON
See examples/basic_usage.rs for a complete example showing encryption, decryption, signing, and verification.
# Run tests
cargo test
# Run example
cargo run --example basic_usage
This library has not undergone professional security audit.
For security vulnerabilities, email security@redasgard.com instead of opening public issues.
MIT License - see LICENSE-MIT