Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate public key from private key #182

Closed
thewh1teagle opened this issue Aug 23, 2021 · 3 comments
Closed

Generate public key from private key #182

thewh1teagle opened this issue Aug 23, 2021 · 3 comments

Comments

@thewh1teagle
Copy link

Hi. Thanks for awesome library.
I wonder if it's possible to generate the public key from the private key?

@berkkirtay
Copy link

I have been using python-rsa for a while and I think it's not been implemented yet. It should be so easy to get public key from a private key since both of them depend on the number e, but to validate it, we also need to know prime numbers since e can't be bigger than the totient. Apologies if it's a feature already implemented.

@thewh1teagle
Copy link
Author

@berkkirtay
I found the solution for that
with help from https://github.com/hvuhsg

pubkey = PublicKey(privateKey.n, privateKey.e)

@bliepp
Copy link

bliepp commented Jan 9, 2022

While this solution is totally fine I would consider it more error prone and less pythonic than a dedicated method or function. A syntax like

pubkey = privkey.public_key()

(see PR #187) encapsulates/black boxes the behavior into the PrivateKey class. In my eyes this makes totally sense since the public key is a direct derivation of the private key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants