Public and private keys are an integral component of cryptocurrencies built on blockchain networks that are part of a larger field of cryptography known as Public Key Cryptography (PKC) or Asymmetric Encryption.
PKC is built on the mathematical primitive of “Trapdoor Functions,” which is a math problem easy to compute in one direction and nearly impossible to reverse.
Solving this problem will take computers enormous amounts of time (i.e., thousands of years) to compute the correct answer. In the context of PKC, such mathematical tricks like Prime Factorization are the trapdoor functions that make reverse-engineering (i.e., forging) cryptographic signatures impossible because it requires the computer to solve a virtually unsolvable math problem.
The general purpose of PKC is to enable secure, private communication using digital signatures in a public channel where there can be potentially malicious eavesdroppers. ****In the context of cryptocurrencies, the goal is to prove that a spent transaction was indeed signed by the owner of the funds, and was not forged, all occurring over a public blockchain network between peers. When you own cryptocurrencies, what you really own is a “private key.” Your “private key” unlocks the right for its owner to spend the associated cryptocurrencies. As it provides access to your cryptocurrencies, it should – as the name suggests – remain private.
In addition to a private key, there is also a public key and there is a cryptographic link between the public key and the private key. It’s possible to recover the public key if you own the private key. However it’s impossible to find the private key using only the public key.
Public and private keys are subsequently analogous to an email address and password, respectively.
Alice can theoretically create billions of public keys (addresses) from her private key, which she only has one of and functions as her private password that only she knows — her secret. Once Alice creates a public key address, that address is publicly available to all users in the network as an address where they can send cryptocurrencies like Bitcoin. Only Alice can access the cryptocurrencies sent to that address since she has the corresponding key to the publicly available address.
Alice’s private key is her digital signature, which she can use to prove that she is the person who spent a transaction or sent a message.
For example, if Alice wants to send Bob a message through a public channel that Charlie is listening to, she can encrypt the message with her private key and sends it to Bob. Alice also produces a special value, called a hash output, with her message that is sent to Bob using his public key. Using the hash output, the message, and his private key, Bob can decrypt and read the message.