Public key encryption encrypts data using the recipient’s public key and it cannot be decrypted without using a matching private key. In other words, you need one key to lock (encrypt the piantext) and another key to unlock (decrypt the cypertext). Important thing is that one key cannot be used in the place of the other.
What is Public Key?
In public key encryption, data encrypted using the recipient’s public key cannot be decrypted without using a matching private key. On the other hand, the public key can be used to decrypt data encrypted by the matching private key. However, public key cannot be used in the place of the private key. If the locking key is made public, then this system can be used by anybody to send private communication to the holder of the unlocking key. This makes sure that the legal recipient (one who has the matching private key) is the only person able to read the message. So, this confirms confidentiality of the communication between two parties.
What is Private Key?
In public key encryption, the private key can only be used to decrypt the data that was encrypted using the matching public key. Similarly, data encrypted using private key can only be decrypted using the matching public key. However, the private key cannot be used in the place of the public key. If the locking key is made private, this system makes it possible to verify that the documents were locked by the owner. The reason is that a message encrypted by the sender can only be opened by a person with the matching public key, thus verifying that the sender did actually hold the private key (meaning that the original and non-tampered message has been received). Therefore, this is used for digital signatures.
What is the difference between Public Key and Private Key?
Public key and private key is the couple of keys used in public key cryptography. If the locking key is made public, then the unlocking key becomes the private key, and vice versa. Public key cannot be used to derive the private key. If the public key is the locking key, then it can be used to send private communication (i.e. to preserve confidentiality). If the private key is the locking key, then the system can be used to verify documents sent by the holder of the private key (i.e. to preserve authenticity).