isislovecruft / python-gnupg

A modified version of python-gnupg, including security patches, extensive documentation, and extra features.
Other
426 stars 171 forks source link

How to read in a private key and return its public key? #289

Open Myzel394 opened 1 year ago

Myzel394 commented 1 year ago

Hey I'm trying to figure out how to read in a private key (from a string in PEM format) and to export its public key.

This is what I've tried:

SERVER_PRIVATE_KEY = gpg.import_keys(base64.b64decode(life_constants.SERVER_PRIVATE_KEY))
SERVER_PUBLIC_KEY = gpg.export_keys(SERVER_PRIVATE_KEY.key_id)

This however only exports a huge public key block (?) but I only want to export the pure minimalistic public key, how do I do that?