0

Python's cryptography module defines the X25519PrivateKey and X25519PublicKey classes. But while X25519PublicKey has a public_bytes() method for serialization, a corresponding private_bytes method on X25519PrivateKey is missing.

Strangely, a _from_private_bytes() classmethod is present, suggesting some way of exporting the key.

How can I export the private key for saving?

Context: I need this for a noiseprotocol connection with static public keys (Noise_XX_*) where I need to provide pre-generated and persisted keys.

Aran-Fey
  • 39,665
  • 11
  • 104
  • 149
Max Tet
  • 735
  • 1
  • 8
  • 16
  • I might be wrong, but I don't think you're supposed to store that key. – Aran-Fey Aug 11 '18 at 09:41
  • Should that not be up to the implementation? Also, there is the `_from_private_bytes()` methods. And other EC private keys can be serialized (see `cryptography.hazmat.backends.openssl.ec._EllipticCurvePrivateKey`) why not this one? – Max Tet Aug 11 '18 at 10:24

0 Answers0