Cryptography
Supernova implements state-of-the-art quantum-resistant cryptography across all blockchain operations. With v1.0.0-RC3, all cryptographic implementations are 100% complete and production-ready.
Overview
Supernova's cryptographic architecture provides:
- Quantum Resistance: Full protection against quantum computing attacks
- Performance: Optimized implementations with hardware acceleration
- Flexibility: Multiple algorithm choices for different use cases
- Future-Proof: Modular design allowing algorithm updates
Implementation Status (v1.0.0-RC3)
Overall Completion: 100% ✅
All quantum signature schemes are fully implemented and tested:
- ✅ ML-DSA (Dilithium): NIST primary standard
- ✅ Falcon: Compact signatures
- ✅ SPHINCS+: Hash-based security
- ✅ Hybrid Mode: Classical + quantum
- ✅ Hardware Acceleration: AVX2/AVX512 support
- ✅ Security Auditing: Comprehensive validation
Signature Algorithms
ML-DSA (Module-Lattice Digital Signature Algorithm)
ML-DSA (formerly CRYSTALS-Dilithium) is NIST's primary quantum-resistant signature standard:
use supernova_crypto::ml_dsa::{MLDSAKeyPair, MLDSALevel};
// Generate keys
let keypair = MLDSAKeyPair::generate(MLDSALevel::ML_DSA_65)?;
// Sign a message
let message = b"Transfer 100 NOVA to Alice";
let signature = keypair.sign(message)?;
// Verify signature
let valid = keypair.public_key().verify(message, &signature)?;
assert!(valid);
Security Levels:
- ML-DSA-44: NIST Level 2 (128-bit quantum security)
- ML-DSA-65: NIST Level 3 (192-bit quantum security) - Default
- ML-DSA-87: NIST Level 5 (256-bit quantum security)
Falcon
Falcon provides the most compact quantum-resistant signatures:
use supernova_crypto::falcon::{FalconKeyPair, FalconDegree};
// Generate Falcon keys
let keypair = FalconKeyPair::generate(FalconDegree::Falcon512)?;
// Sign with compression
let signature = keypair.sign_compressed(message)?;
// Signature is only 690 bytes for Falcon-512
println!("Signature size: {} bytes", signature.len());
Variants:
- Falcon-512: NIST Level 1 (690 byte signatures)
- Falcon-1024: NIST Level 5 (1,280 byte signatures)
SPHINCS+
SPHINCS+ provides hash-based signatures for maximum security:
use supernova_crypto::sphincs::{SPHINCSKeyPair, SPHINCSParams};
// Configure SPHINCS+ parameters
let params = SPHINCSParams::new()
.security_level(192)
.hash_function(HashFunction::SHAKE256)
.variant(Variant::Robust)
.size(Size::Small);
let keypair = SPHINCSKeyPair::generate(params)?;
Features:
- Stateless operation
- Based only on hash functions
- Maximum long-term security
- Large signatures but unbreakable
Hash Functions
SHA-3 Family
Supernova uses SHA-3 for all hashing operations:
use supernova_crypto::hash::{sha3_256, shake256};
// Fixed-length output
let hash = sha3_256(data);
// Variable-length output
let extended = shake256(data, 64); // 64 byte output
Merkle Trees
Quantum-resistant Merkle trees using SHA-3:
use supernova_crypto::merkle::{MerkleTree, SHA3Hasher};
let tree = MerkleTree::<SHA3Hasher>::new();
tree.add_leaf(transaction1.hash());
tree.add_leaf(transaction2.hash());
let root = tree.root();
let proof = tree.generate_proof(0)?;
Key Derivation
Hierarchical Deterministic Keys
HD key derivation with quantum resistance:
use supernova_crypto::hd::{HDKeychain, DerivationPath};
// Generate master key
let master = HDKeychain::from_seed(seed, AlgorithmType::ML_DSA)?;
// Derive child keys
let account = master.derive_path("m/44'/12345'/0'")?;
let address = account.derive_child(0)?;
Key Encapsulation
Kyber for quantum-secure key exchange:
use supernova_crypto::kem::{Kyber, KyberLevel};
// Generate KEM keypair
let (public_key, secret_key) = Kyber::keypair(KyberLevel::Kyber768)?;
// Encapsulate shared secret
let (ciphertext, shared_secret) = Kyber::encapsulate(&public_key)?;
// Decapsulate on receiver side
let recovered_secret = Kyber::decapsulate(&ciphertext, &secret_key)?;
Performance Optimization
Hardware Acceleration
Automatic detection and use of CPU features:
use supernova_crypto::acceleration::{detect_features, set_acceleration};
// Detect available features
let features = detect_features();
if features.has_avx2() {
set_acceleration(Acceleration::AVX2);
} else if features.has_avx512() {
set_acceleration(Acceleration::AVX512);
}
Batch Verification
Efficient batch signature verification:
use supernova_crypto::batch::{BatchVerifier, VerificationItem};
let mut verifier = BatchVerifier::new();
// Add signatures to batch
for (message, signature, public_key) in signatures {
verifier.add(VerificationItem {
message,
signature,
public_key,
});
}
// Verify all at once (much faster)
let all_valid = verifier.verify_batch()?;
Security Features
Side-Channel Protection
Constant-time operations to prevent timing attacks:
use supernova_crypto::secure::{constant_time_compare, secure_zero};
// Constant-time comparison
let equal = constant_time_compare(&secret1, &secret2);
// Secure memory clearing
secure_zero(&mut sensitive_data);
Random Number Generation
Cryptographically secure RNG:
use supernova_crypto::rng::{SecureRng, RngSource};
// Use hardware RNG if available
let mut rng = SecureRng::new(RngSource::Hardware)?;
// Generate random bytes
let mut key = [0u8; 32];
rng.fill_bytes(&mut key)?;
Integration Examples
Transaction Signing
use supernova_crypto::transaction::{Transaction, SignatureType};
let mut tx = Transaction::new()
.from(sender_address)
.to(recipient_address)
.amount(Amount::from_nova(100))
.build()?;
// Sign with ML-DSA
tx.sign(private_key, SignatureType::ML_DSA_65)?;
// Verify before broadcasting
assert!(tx.verify()?);
Block Header Signing
use supernova_crypto::block::{BlockHeader, MinerSignature};
let mut header = BlockHeader {
version: 1,
previous_hash: prev_block.hash(),
merkle_root: transaction_tree.root(),
timestamp: current_time(),
difficulty: current_difficulty,
nonce: 0,
};
// Mine and sign
let signature = MinerSignature::create(&header, miner_key)?;
header.set_signature(signature);
Best Practices
Algorithm Selection
Choose the right algorithm for your use case:
Use Case | Recommended Algorithm | Reason |
---|---|---|
General transactions | ML-DSA-65 | Balanced performance/security |
High-frequency trading | Falcon-512 | Smallest signatures |
Long-term storage | SPHINCS+-192 | Maximum security |
Lightning Network | ML-DSA-65 | NIST standard |
Key Management
Secure key storage and handling:
use supernova_crypto::keystore::{KeyStore, EncryptionMethod};
// Create encrypted keystore
let keystore = KeyStore::new(EncryptionMethod::AES256_GCM);
// Store key with password
keystore.store_key(
"my_key",
&private_key,
"strong_password"
)?;
// Retrieve key
let key = keystore.get_key("my_key", "strong_password")?;
Migration from Classical
Transitioning from ECDSA to quantum-resistant:
use supernova_crypto::migration::{MigrationHelper, HybridSigner};
// Create hybrid signer for transition period
let hybrid = HybridSigner::new(
ecdsa_key,
ml_dsa_key
);
// Sign with both algorithms
let signature = hybrid.sign(message)?;
// Gradually phase out ECDSA
if network_supports_quantum_only() {
let signature = ml_dsa_key.sign(message)?;
}
Performance Benchmarks
Signature Performance (v1.0.0-RC3)
Operation | ML-DSA-65 | Falcon-512 | SPHINCS+-192f |
---|---|---|---|
Key Generation | 0.2 ms | 8.0 ms | 0.5 ms |
Signing | 0.5 ms | 0.4 ms | 8.0 ms |
Verification | 0.2 ms | 0.1 ms | 0.2 ms |
Signature Size | 3,293 B | 690 B | 35,664 B |
Throughput Comparison
Algorithm | Single-threaded TPS | Multi-threaded TPS (8 cores) |
---|---|---|
ECDSA (baseline) | 15,000 | 100,000 |
ML-DSA-65 | 5,000 | 35,000 |
Falcon-512 | 10,000 | 70,000 |
Hybrid Mode | 3,000 | 20,000 |
Security Analysis
Quantum Resistance
All algorithms resist known quantum attacks:
- Shor's Algorithm: No impact (not based on factoring/discrete log)
- Grover's Algorithm: Security levels account for square root speedup
- Future Algorithms: Hash-based fallback (SPHINCS+) provides insurance
Classical Security
Maintains strong classical security:
- ML-DSA: Based on Module-LWE problem
- Falcon: Based on NTRU lattice problem
- SPHINCS+: Based on hash function security
Conclusion
Supernova's cryptographic implementation provides comprehensive quantum resistance while maintaining practical performance. The modular design allows for future updates as post-quantum cryptography evolves, ensuring long-term security for the network.