---
title: "Public-Key Cryptography and Key Exchange"
description: "A key pair splits the secret: one half can be published, and only the other half undoes what the first did. That solves the problem symmetric ciphers cannot, which is agreeing on a shared key with som"
canonical: https://lightmysky.com/en/learn/computing/public-key-cryptography-and-key-exchange
source: https://lightmysky.com/learn/computing/public-key-cryptography-and-key-exchange.md
license: https://lightmysky.com/en/license
retrieved: 2026-12-04
---

> **Using this content.** You may index it, quote short parts, and use it to answer a person's question, if you name LightMySky and link to the page. You may train models on it.
> Please do not republish, resell or serve our lessons and questions as another product.
> [Topic data credits and licenses](https://github.com/withmarbleapp/os-taxonomy#attribution) (ODbL 1.0 for the database and CC BY-SA 4.0 for the topic text).
> Full license: https://lightmysky.com/en/license

> **Agent view.** This is the Markdown twin of the page, for tools and assistants.
> When to use this site, and the call that answers each job: https://lightmysky.com/agent-instructions.md
> API description (OpenAPI 3.1): https://lightmysky.com/openapi.json · Authentication: https://lightmysky.com/auth.md
> Pricing: https://lightmysky.com/pricing.md · Catalog: https://lightmysky.com/llms.txt · Full catalog: https://lightmysky.com/llms-full.txt
> Every machine-readable file on this domain: https://lightmysky.com/.well-known/ai-catalog.json
> Ask for Markdown with `Accept: text/markdown`, a `.md` address, or `?mode=agent`.

# Public-Key Cryptography and Key Exchange

A key pair splits the secret: one half can be published, and only the other half undoes what the first did. That solves the problem symmetric ciphers cannot, which is agreeing on a shared key with someone you have never met, over a line somebody is reading.

Subject: Computing · Area: Networks & Security · Ages 20 to 22
Page: https://lightmysky.com/en/learn/computing/public-key-cryptography-and-key-exchange

## Ready when they can

- Explain what each half of a key pair can do and what it cannot
- Follow a key exchange and say what an eavesdropper has at the end of it
- Say why public-key operations are used to set up a symmetric key rather than to carry the data

## Lesson: Split the secret, share half openly

A key pair splits the secret in two. One half, the public key, can be published for everyone to see. The other half, the private key, is never revealed. A message locked with the public half can only be unlocked with the matching private half, so strangers can write to you while only you can read.

*(drawing: Scrambling gives 11 from 1 times 3 plus 2 times 4. The undoing matrix [[1,-2],[0,1]] subtracts the 2 copies back off.)*

That split solves the problem symmetric ciphers cannot: two strangers agree on a shared secret over a line somebody is recording. Every message of the exchange is overheard, yet the watcher ends with nothing usable. The toy matrix fails this test: anyone seeing the scrambling matrix can compute its undoing matrix with a short formula, so it can never have a safe public half.

Real public-key systems use math where the undo half stays hidden even when the scramble half is published. They are also slower, so computers use them just to swap a secret key, then switch to fast symmetric encryption for the real conversation. Publish the scramble half, hide the undo half, and let the fast cipher carry the chat.

*(drawing: First row gives 1 times 5 plus 2 times 1, which is 7. The second number stays 1, so the result is (7, 1).)*

In a real exchange nothing sent reveals the secret. The watcher records locked pieces only, and locked pieces without the private half reveal nothing usable. That is why the watcher ends with recordings but no secret.

**Recap.** Publish one half, hide the other, agree secrets over watched lines, then hand the chat to the fast cipher.

## Practice

11 questions on this page, each with its working shown.

## Needs first

- [Fermat's Little Theorem and Euler's Theorem](https://lightmysky.com/en/learn/mathematics/fermats-little-theorem-and-eulers-theorem)
- [Symmetric Encryption and What a Cipher Promises](https://lightmysky.com/en/learn/computing/symmetric-encryption-and-what-a-cipher-promises)

## Opens up

- [TLS: Putting the Pieces Together](https://lightmysky.com/en/learn/computing/tls-putting-the-pieces-together)
- [Hashes, Signatures and Certificates](https://lightmysky.com/en/learn/computing/hashes-signatures-and-certificates)
- [Cryptographic Security Definitions and Proof by Reduction](https://lightmysky.com/en/learn/computing/cryptographic-security-definitions-and-proof-by-reduction)
