What is a Public Key?
A public key is the key that is disclosed to third parties within a public key infrastructure (PKI). In public key cryptography, a public key is paired with a corresponding private key. While the public key is shared openly, the private key must be kept confidential by its owner.
Before the advent of public key cryptography, symmetric key cryptography was widely used. In this method, the same key was used for both encryption and decryption, and the key was shared between communication parties to enable secure communications. However, if the key was intercepted during the sharing process, the encryption's security would be compromised. Public key cryptography was developed to address this issue.
In public key cryptography, the key owner first shares the public key with the communication partner. The communication partner uses this public key to encrypt a message or data and sends the encrypted message to the key owner. The key owner then decrypts the message using the corresponding private key. Since the private key is never transmitted over the communication channel, the risk of interception is greatly reduced, enhancing security.
The most widely used public key encryption system today is the RSA algorithm. RSA uses a paired key structure where data encrypted with one key (e.g., the public key) can only be decrypted with the other (e.g., the private key), and vice versa. This allows for flexible use cases, such as encrypting data with the public key and decrypting with the private key—or encrypting data with the private key and decrypting with the public key.
This latter property is utilized in digital signatures. A document that can be decrypted with a specific public key must have been encrypted with the corresponding private key, proving it was authored by the owner of that private key. However, it is important to note that RSA's public and private keys are not symmetric. While a public key can be generated from the corresponding private key, generating the private key from the public key is computationally infeasible. RSA's security relies on the difficulty of factoring large numbers into their prime components. To maintain security, RSA keys must be sufficiently long to keep up with advancements in computing power and potential new decryption algorithms. Over time, key lengths and algorithms are periodically updated to ensure continued security.