---
title: "Key Pair"
---

A cryptography key pair consists of two related but distinct cryptographic keys:

1. **Private Key**: A secret key that is used to decrypt, sign, or authenticate data. It's called "private" because it should be kept confidential and secure to prevent unauthorized access.
2. **Public Key**: A publicly accessible key that is used to encrypt, verify, or authenticate data. It's called "public" because it can be shared freely without compromising the security of the system.

## How do key pairs work?

Here's a simplified overview of how key pairs are used in various cryptographic scenarios:

### Encryption

- Alice wants to send a secure message to Bob.
- Bob generates a key pair and shares his public key with Alice.
- Alice uses Bob's public key to encrypt the message.
- Bob uses his private key to decrypt the message.

### Digital Signatures

- Alice wants to send a document to Bob and prove its authenticity.
- Alice generates a key pair and uses her private key to sign the document.
- Bob uses Alice's public key to verify the signature and ensure the document hasn't been tampered with.

### Authentication

- Alice wants to access a secure system or service.
- The system generates a key pair and shares its public key with Alice.
- Alice uses the system's public key to encrypt a challenge or password.
- The system uses its private key to decrypt the challenge or password and authenticate Alice.

### Key Pair Properties

- **Asymmetric**: Key pairs are asymmetric, meaning that the private key is not easily derived from the public key.
- **Mathematical relationship**: The private and public keys are mathematically related, allowing for encryption, decryption, signing, and verification.
- **Unique**: Each key pair is unique, ensuring that data encrypted with a public key can only be decrypted with the corresponding private key.

### Types of Key Pairs

- **RSA (Rivest-Shamir-Adleman)**: A popular algorithm used for encryption, decryption, and digital signatures.
- **Elliptic Curve Cryptography (ECC)**: A more modern algorithm used for encryption, decryption, and digital signatures, offering better security with smaller key sizes.
- **Diffie-Hellman (DH)**: A key exchange algorithm used to establish a shared secret key between two parties.

In summary, cryptography key pairs are a fundamental component of secure online communications, enabling encryption, digital signatures, and authentication. By using a pair of related but distinct keys, key pairs provide a secure way to protect data and ensure its authenticity.