diff --git a/projects/pi-nexus-iam/quantum-crypto/keygen.py b/projects/pi-nexus-iam/quantum-crypto/keygen.py new file mode 100644 index 000000000..aa1239c17 --- /dev/null +++ b/projects/pi-nexus-iam/quantum-crypto/keygen.py @@ -0,0 +1,20 @@ +import os +from cryptography.hazmat.primitives import serialization +from cryptography.hazmat.primitives.asymmetric import ec +from cryptography.hazmat.backends import default_backend + +def generate_key_pair(): + key = ec.generate_private_key( + ec.SECP256R1(), + default_backend() + ) + private_key = key.private_bytes( + encoding=serialization.Encoding.PEM, + format=serialization.PrivateFormat.TraditionalOpenSSL, + encryption_algorithm=serialization.NoEncryption() + ) + public_key = key.public_key().public_bytes( + encoding=serialization.Encoding.OpenSSH, + format=serialization.PublicFormat.OpenSSH + ) + return private_key, public_key