I have a follow up question to Given a private key, is it possible to derive it’s public key?
Are the public and the private keys the 'same' (in the sense that you just choose to make one public) or can you do more with the private key than with the public key?
EDIT - to better state my question:
When the two keys are generated, could I just randomly choose one of them to be the public key?
Public key cryptography is a method of encrypting or signing data with two different keys and making one of the keys, the public key, available for anyone to use. The other key is known as the private key. Data encrypted with the public key can only be decrypted with the private key.
Public and private keys: an exampleBob wants to send Alice an encrypted email. To do this, Bob takes Alice's public key and encrypts his message to her. Then, when Alice receives the message, she takes the private key that is known only to her in order to decrypt the message from Bob.
Using Public Key Pairs To Ensure Both Security and Identity The message can be transmitted openly over the Internet, and since only the recipient can decrypt the message with the appropriate private key, secure transmission is ensured.
Some paper descriptions present roles of public and private keys as quite symmetrical but you definitely can't swap roles of private and public key in real world.
Common usage:
There is several reasons for that:
you don't want to leave a choice to the user as to which key should be published and which not. The public key is published worldwide and you can consider it as your public identity. The private part is needed when you have to prove to someone else that you have more insight than others about this identity: you can read messages sent to it, you are able to sign messages that can be verifyed by anyone who knows your public id. If what part of public/private key to publish were left to the user you'll end end with users publishing both. But that's not the main reason.
when you have private keys, you really have both keys every common implementation I know offer tools to extract public keys from private files. That's true for pgp, gpg, openssl. It means so called private key files store both private and public keys as described in algorithms. That's by design.
For exemple with openssl the sequence of commands to generate a RSA key pair can be:
openssl genrsa -out private.key 2048
openssl rsa -in private.key -pubout -out public.key
It should be clear enough that the first command generate both keys in the private key file and that the public key is merely extracted from it.
The consequence is that if your private key is ever compromized, both your keys would be compromized. The other way around is secure, you can't deduce the private key if you know the public key neither from the file nor from a mathematical attack.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With