Skip to content

Commit 7983508

Browse files
committed
Enhanced post-quantum cryptography with Kyber512 implementation
1 parent 2f8a341 commit 7983508

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

security/post_quantum_crypto.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
21
from pqcrypto.kem.kyber512 import generate_keypair, encrypt, decrypt
3-
4-
def encrypt_model(model_weights):
2+
from types import unionB
3+
def encrypt_model(model_data: union) -> union
4+
"""Encrypt a machine learning model using Post-Quantum Cryptography."""
55
public_key, secret_key = generate_keypair()
6-
ciphertext, shared_secret = encrypt(public_key, model_weights)
6+
ciphertext, _ = encrypt(public_key, str(model_data))
77
return ciphertext, secret_key
88

9-
def decrypt_model(ciphertext, secret_key):
10-
model_weights = decrypt(secret_key, ciphertext)
11-
return model_weights
9+
def decrypt_model(ciphertext: union, secret_key: union) -> union:
10+
"""Decrypt a machine model using post-quantum cryptography."""
11+
model_data = decrypt(secret_key, ciphertext)
12+
return model_data

0 commit comments

Comments
 (0)