# WHAT ARE PUBLIC KEYS AND PRIVATE KEYS?

*What are public and private keys? Here, we explain how they work – and what you need to know.*

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.

The goal of PKC is to trivially transition from one state to another while making reversing the process nearly impossible, and in the process, proving you have a secret without exposing that secret. The product is subsequently a one-way mathematical function, which makes it ideal for validating the authenticity of something (i.e., a transaction) because it cannot be forged. PKC relies on a two-key model, the public and private key, often represented by a padlock (public key) and the actual key to access the padlock (the private key).

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.

Charlie is not capable of reading the message because he only has Alice’s public key and his own private/public key pair. This is the brilliance of trapdoor functions in action. Charlie cannot reverse-engineer the message or private key of Alice because it is built using a trapdoor function.

In Bitcoin, transactions are a series of users sending and receiving bitcoins to each others’ public addresses as inputs and outputs in Bitcoin’s UTXO transaction model. Alice can publish her public key on the web, and people can send bitcoins to that address knowing that Alice is the owner of the private key to those funds.

More generally, nodes (people running the Bitcoin software) in Bitcoin automatically check and validate transactions in the network to make sure none of them were forged using basic consensus rules and cryptographic proofs that the public/private key pairs are valid (Proof of work) .

**As a result, it is nearly impossible to forge transactions in cryptocurrencies like Bitcoin that use PKC since they are protected by the assumptions of mathematical proofs.***Keep learning! If you enjoy getting to grips with crypto and blockchain, check out our School of Block video*How to Keep Your Crypto Safe.