-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathencryption.py
More file actions
30 lines (21 loc) · 960 Bytes
/
Copy pathencryption.py
File metadata and controls
30 lines (21 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""
Quantum-safe encryption module using Kyber KEM.
This module demonstrates post-quantum cryptography for securing
sensitive data in the Face-Recon system.
Note: Requires pqcrypto package: pip install pqcrypto
"""
try:
from pqcrypto.kem.kyber import decrypt, encrypt, generate_keypair
# Generate quantum-safe key pair
public_key, private_key = generate_keypair()
# Encrypt: generates ciphertext and shared secret
ciphertext, shared_secret = encrypt(public_key)
# Decrypt: recovers the shared secret
decrypted_secret = decrypt(ciphertext, private_key)
# Verify encryption works
assert shared_secret == decrypted_secret, "Encryption/decryption failed!"
print(f"Secure key established: {len(decrypted_secret)} bytes")
print("Quantum-safe encryption ready!")
except ImportError:
print("Warning: pqcrypto not installed. Install with: pip install pqcrypto")
print("Quantum-safe encryption unavailable.")