python-rsa icon indicating copy to clipboard operation
python-rsa copied to clipboard

Generate PublicKey from PrivateKey

Open bliepp opened this issue 3 years ago • 4 comments

I know it's not that much of an important feature as a public key can be generated from a private key by simply doing

pubkey = rsa.PublicKey(privkey.n, privkey.e)

but I still find a separate method to be convenient as it eliminates a possible source of errors and increases readability.

With the rather simple implementation this would be just

pubkey = privkey.public_key()

bliepp avatar Jan 09 '22 20:01 bliepp

Thanks for the PR. I agree with you that it's good to have a dedicated method for this.

Before I can accept the PR it needs a bit of love, though. The new code should be covered by a unit test.

Maybe you could also write a little bit about this in the "Generating Keys" section of doc/usage.rst? Such new, useful functionality ought to be documented as well.

sybrenstuvel avatar Jan 11 '22 12:01 sybrenstuvel

Thank you for your reply. I've written a test case in the KeyGenTest class and some documentation into usage.rst as you suggested.

Hope this is fine now.

bliepp avatar Jan 11 '22 14:01 bliepp

It's been a week since I fixed this PR. Is this okay now or is there something I need to change?

bliepp avatar Jan 20 '22 14:01 bliepp

From a glance it looks good, thanks. For personal reasons I can't spend more brain power on this now, sorry. I'll get back to you, no worries. If there happen to be things to change, I'll be explicit in what & how.

sybrenstuvel avatar Jan 20 '22 16:01 sybrenstuvel