from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives.asymmetric import x25519 private_key = x25519.X25519PrivateKey.generate() public_key = private_key.public_key() private_key_bytes = private_key.private_bytes( encoding=serialization.Encoding.Raw, format=serialization.PrivateFormat.Raw, encryption_algorithm=serialization.NoEncryption(), ) public_key_bytes = public_key.public_bytes( encoding=serialization.Encoding.Raw, format=serialization.PublicFormat.Raw ) def cast_bytes(byte_data): return ", ".join(f"0x{byte:02x}" for byte in byte_data) print("Private Key:", cast_bytes(private_key_bytes)) print("Public Key:", cast_bytes(public_key_bytes))