kids encyclopedia robot

Public-key cryptography facts for kids

Kids Encyclopedia Facts
Public-key-crypto-1
An unpredictable (often large and random) number helps create a pair of special keys for a new type of code.
Public key encryption
With public key encryption, anyone can use a public key to lock messages. But only the person with the matching private key can unlock them. The private key must be kept secret!
Public key shared secret
In the Diffie–Hellman method, two people, like Alice and Bob, each make a public and private key. They share their public keys. Then, they can both figure out a secret code that only they know. This secret code can then be used for faster, everyday encryption.
Private key signing
Alice can sign a message with her private key. Bob can then use Alice's public key to check that the message really came from Alice and hasn't been changed. The message itself isn't hidden, just verified.

Public-key cryptography, also called asymmetric cryptography, is a clever way to send secret messages and prove who sent them. It uses two special keys that are linked together: a public key and a private key. These keys are made using math problems that are easy to do one way but very hard to undo.

The public key can be shared with anyone, like putting it on a website. But the private key must be kept a secret. If someone gets your private key, your messages won't be safe anymore.

When you use a public-key encryption system, anyone can use your public key to lock a message. This locked message is called a ciphertext. Only you, with your secret private key, can unlock the ciphertext to read the original message.

Imagine a journalist wants people to send them secret tips. The journalist can put their public key on their website. Anyone can use this key to encrypt a message and send it. Only the journalist, who has the private key, can read these messages. If someone tries to snoop on the email, they won't be able to read the secret message.

Public-key cryptography is also used for digital signatures. This is like a super-secure electronic signature. Someone can use their private key to "sign" a message. Anyone with their public key can then check if the signature is real and if the message hasn't been changed. Someone who doesn't have the private key can't fake a signature that will pass this check.

For example, a company that makes computer software can sign their updates with their private key. Your computer has their public key. When you download an update, your computer uses the public key to check the signature. If it's real, your computer knows the update came from the company and hasn't been messed with. This stops bad guys from sending fake updates that could harm your computer.

Public-key methods are super important for keeping things safe online. They help make sure messages are private, real, and that people can't deny sending them later. They are used in many internet tools like TLS (which makes websites secure, like when you see "https://"), SSH, and PGP. Some public-key methods help share secret keys, some create digital signatures, and some do both.

Compared to symmetric encryption (where both sides use the same secret key), public-key methods are slower. So, modern systems often use both. They use the slower public-key method to securely share a secret key, and then use that secret key with the faster symmetric method to send most of the data.

How Public-Key Cryptography Works

Before the 1970s, all secret codes used the same key for both locking and unlocking messages. This key had to be shared secretly first, like by meeting in person. This was hard to do, especially if many people needed to talk securely or if keys had to be changed often.

But with public-key systems, public keys can be shared widely. Only the private key needs to be kept secret by its owner.

Two main ways public-key cryptography is used are:

  • Public key encryption: A message is locked using the receiver's public key. Only the person with the matching private key can unlock and read it. This keeps the message private.
  • Digital signatures: A message is signed using the sender's private key. Anyone with the sender's public key can check this signature. This proves the sender really sent the message and that it hasn't been changed.

Making Sure Public Keys Are Real

How do you know that a public key really belongs to the person it claims to? This is important because a bad guy could try to give you a fake public key. There are a few ways to check:

  • A public key infrastructure (PKI) uses trusted groups called certificate authorities. These groups check who owns a key pair and then give out a digital certificate to prove it. Websites use this system (like when you see a padlock icon in your browser).
  • A "web of trust" is a different way. Here, people trust each other's keys directly. It's like a network where friends vouch for their friends' keys. PGP uses this method.

What Public-Key Cryptography Is Used For

The most common use is to make sure messages stay private. You lock a message with someone's public key, and only they can unlock it with their private key.

Another big use is for digital signatures. These prove who sent a message and that it hasn't been changed.

Public-key cryptography also helps with:

  • Making sure someone can't deny sending a document or message later.
  • Digital cash.
  • Secure ways to agree on secret keys using passwords.
  • Time-stamping services to prove when something happened.

Combining Public and Symmetric Keys

Public-key methods are usually much slower than symmetric-key methods. So, many systems combine them. This is called a hybrid cryptosystem.

Here's how it works: 1. First, a public-key method is used to securely share a new, secret symmetric key between two people. 2. Then, this shared symmetric key is used with a faster symmetric-key method to send all the actual data.

This way, you get the security of public-key methods for sharing the first secret, and the speed of symmetric-key methods for everything else. Programs like PGP, SSH, and TLS (for secure websites) use this smart combination.

Challenges and Weaknesses

Like all security systems, public-key cryptography has some challenges. The biggest risk is if someone finds out your private key. If that happens, all your secret messages and digital signatures are no longer safe.

Also, new types of computers called quantum computers might be able to break some of today's public-key codes in the future. Scientists are already working on new "quantum-resistant" codes to prepare for this.

Attacks on Algorithms

Some public-key methods can be attacked by trying every possible key (a "brute-force attack"). But if the key is long enough, this would take too much computing power to be practical. However, some specific attacks have been found for certain algorithms, like RSA, that are faster than brute-force, but still not practical enough to break them easily.

Changing Public Keys

One big danger is a "man-in-the-middle" attack. This is when a bad guy secretly intercepts the public key you're trying to get and replaces it with their own fake public key. Then, they can read and change your messages without you knowing.

Imagine you want to send a secret message to your friend. You ask for their public key. A hacker intercepts this request and sends you *their* public key instead, pretending it's your friend's. You encrypt your message with the hacker's key (thinking it's your friend's). The hacker then decrypts it, reads it, maybe changes it, and then re-encrypts it with your friend's *real* public key before sending it on. Your friend gets the message and thinks it's fine.

These attacks are harder to do with modern security, but they can happen, especially on public networks like the internet. This is why checking if a public key is real (using PKI or web of trust) is so important.

Public Key Infrastructure Issues

While PKI helps prevent man-in-the-middle attacks, it also has potential weaknesses. The organizations that give out digital certificates (certificate authorities) must be completely trustworthy. If a certificate authority is hacked or makes a mistake, bad guys could get fake certificates, making the whole system unsafe.

For example, web browsers come with a list of trusted certificate authorities. If a hacker could trick one of these authorities into giving them a fake certificate for a website, they could pretend to be that website and trick users.

A Brief History

For a long time, people had to share secret keys in person or through trusted messengers. This was very difficult.

Early Ideas

In 1874, a scientist named William Stanley Jevons wrote about a math problem: finding two numbers that multiply to a very large number. He said, "I think it unlikely that anyone but myself will ever know." This was an early idea about how some math problems are easy one way (multiplying) but very hard the other way (finding the original numbers). This idea is key to public-key cryptography.

Secret Discoveries

In the 1970s, some British cryptographers at GCHQ (a UK government agency) secretly discovered public-key cryptography.

These discoveries were kept secret for military reasons until 1997.

Public Discoveries

In 1976, Whitfield Diffie and Martin Hellman published their work on a public-key system. Their method for sharing a secret key became known as Diffie–Hellman key exchange. This was the first time a practical way to share a secret key over an open channel was made public.

In 1977, Ron Rivest, Adi Shamir, and Leonard Adleman at MIT independently invented an algorithm similar to Cocks's secret discovery. They published their work in 1978, and it became famous as RSA, named after their initials. RSA uses very large prime numbers to lock and unlock messages and create digital signatures. Its safety comes from how incredibly hard it is to factor (break down) very large numbers into their prime parts.

Since the 1970s, many other public-key methods have been developed, including ECC.

Examples of Public-Key Methods

Here are some well-known public-key methods used today:

  • Diffie–Hellman key exchange (for sharing secret keys)
  • Digital Signature Algorithm (for digital signatures)
  • RSA (for both encryption and digital signatures)
  • Elliptic-curve cryptography (a newer, very efficient type)

Some public-key methods that are not yet widely used:

  • Kyber
  • McEliece cryptosystem

An example of a public-key method that was found to be insecure:

  • Merkle–Hellman knapsack cryptosystem

Here are some internet tools and protocols that use public-key methods:

  • S/MIME (for secure email)
  • PGP (for secure communication)
  • IPsec (for secure internet connections)
  • TLS (for secure websites, like HTTPS)
  • SSH (for secure remote access to computers)
  • Bitcoin (for secure digital money)

Images for kids

See also

Kids robot.svg In Spanish: Criptografía asimétrica para niños

kids search engine
Public-key cryptography Facts for Kids. Kiddle Encyclopedia.