Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

After reading about public/private key cryptography, there are still a few points I don't really understand.

Based on the way (I understand) challenges work, the public key is used to encrypt a sequence which the private key can be used to decrypt:

  1. When a key pair is freshly generated, does it matter which key that is chosen as the private key since the opposite key can be used for encryption?
  2. Does this apply to all known and/or hypothetic asymmetric encryption algorithms?
share|improve this question
up vote 11 down vote accepted

This depends on the public-key system (algorithm).

For RSA, technically the private and public key (i.e. the exponents, the keys share the same modulus) are symmetric, you can swap them, and it still works.

But you usually don't want to do this: The public exponent is usually a small number (like $3$ or $2^{16} + 1$) in order to speed up encryption/signature verification, and can thus be easily guessed. You don't want this property for a private key.

Also, in practice the private key is often not just the exponent $d$ and modulus $n$, but also the factors of the modulus (i.e. $p$ and $q$), in order to speed up decryption or signature. That kind of key certainly doesn't work as a public key.

For other public-key systems (like ElGamal/DSA, Diffie-Hellman, or EC), the relation between public and private key is not symmetric at all. In the examples mentioned you have a private key $x$ and a public key $y = g^x$ (with some kind of exponentiation operation which is difficult to reverse).

In these cases, you certainly can't swap out public and private key.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.