Given a private key, is it possible to derive its public key?

Viewed 40842

From whatever little I understand by reading various material, public-private key pair are the basis of asymmetric encryption and also something about choosing 2 prime numbers (which is roughly your private key) and multiplying them (which is roughly your public key). It appears to me that it is possible to generate a public key if you know the private key. Is it correct or I am mistaking something?

What made me more confusing was that it is not possible to serialize the RSA key to XML with only private key (using .NET class RSACryptoServiceProvider). Not sure whether this limitation is intentional or not!

10 Answers

That depends on the crypto system.

In RSA, we have (citing Wikipedia):

The public key consists of the modulus n and the public (or encryption) exponent e. The private key consists of the modulus n and the private (or decryption) exponent d which must be kept secret.

Now if we have n and d (the private key), we are only missing e for the public key. But e is often fairly small (less than three digits), or even fixed (a common value is 65537). In these cases getting the public key is trivial.

For Elliptic Curve Diffie-Hellman, the private key is d, and the public key dG (with G also public), so it's trivial as well.

It depends on the algorithm, and what you mean by "private key".

RSA private keys are often stored in their "Chinese Remainder Theorem" form. For example, the RSAPrivateKey structure defined in PKCS #1 and re-used by many other crypto standards take this form. This form includes the two secret numbers often denoted p and q, from which the totient is computed. With totient and the private exponent, the public exponent is quickly computed.

In any case, most RSA key pairs use 65537 as the public exponent, and the modulus is always carried as part of the private key.

In ANY public key crypto system the public key is mathematically related to the private key. It's very simple.

The public key is derived from the private key at generation time, and with the private key at any point in the future it is possible to re-derive the public key easily.

It is not feasible to go the other way. Given a public key it is not easy to derive the private key. That's why we can safely share public keys with other people. If you have enough time/CPU cycles you could brute force it but it's probably easier to wait for a mathematical attack on the key.

Yes it is possible to fetch the public key using the private key. It could be done using openssl. Please refer the below command to get the public key using the private key.

openssl rsa -in privatekey.pem -pubout

Please refer this screenshot : Fetch public key using private key

Yes with access to the private key the public key can be generated

It is theoretically possible but for large keys computationally infeasible.

Related