Public Key encryption is a method to keep secrets between two parties.
This method of encryption has one drawback, it is takes more computations but is more difficult to hack. Commonly, public key encryption is used to initiate handshakes and then private key encryption is used afterwards; however, that topic will be covered in another article.
The encryption uses certain items, a public item, one which anyone can find out, and two private items, one which each party member holds secretly.
The algorithm follows that, each party can compute an item by using a combination of the private item and the public item. The resulting item is given to the other party, which anyone can obtain as well.
After the exchange of the newly computed items, each party computes the shared secret, commonly the private key.