Cryptography / Concepts

Asymmetric Cryptography

Asymmetric cryptography uses mathematically linked pairs of keys: a Public Key that can be shared freely with any endpoint, and a Private Key that must be kept secret by its owner. Asymmetric primitives enable public-key distribution without a pre-shared secret channel and establish ephemeral keys for transport security — but distribution alone does not establish whose key it is; that requires an authenticated binding, such as a CA-issued certificate or an out-of-band fingerprint check. The Certificates page covers the broader Public Key Infrastructure (PKI) trust, validation, issuance, renewal, and revocation lifecycle. A digital signature validates under a public key for specific data, while attribution to a signer additionally depends on that binding and evidence that the private key was not shared, delegated, or compromised.

Asymmetric Paradigm: Linked Key Pairs

Unlike symmetric ciphers which rely on a single shared key, asymmetric cryptography generates a key pair (Kpub, Kpriv) with complementary, non-interchangeable roles. For encryption/decryption and sign/verify schemes specifically, an operation performed with one key is inverted or verified by the corresponding key in the pair. Key Encapsulation Mechanisms (KEMs, e.g. ML-KEM) and key-agreement protocols (ECDH/X25519) use the pair differently: encapsulation/decapsulation and Diffie-Hellman-style agreement each compute a shared value from both parties’ key material rather than one key simply inverting an operation the other key performed — the “one key locks, the other unlocks” framing describes encryption and signing, not every asymmetric operation.

Diagram showing asymmetric cryptography: encryption using public key, decryption using private key, signing using private key, verification using public key.

Public and private keys have complementary, non-interchangeable roles

Three Distinct Operations

  1. Public-Key Encryption (RSA-OAEP direct, or HPKE hybrid): With RSA-OAEP, the sender encrypts a short payload directly under the recipient’s public key. HPKE (RFC 9180) instead uses the public key only to encapsulate a KEM-derived shared secret; a KDF expands that secret into keys for an AEAD cipher, which performs the actual (arbitrary-length) encryption. Either way, only the recipient’s private key can recover the secret.
  2. Digital Signatures (Ed25519 / RSA-PSS): The sender computes a signature over data using their private key; anyone holding the corresponding public key can verify that signature for the data. Origin attribution additionally requires a trusted key-to-signer binding and uncompromised key custody.
  3. Key Agreement (ECDHE / X25519): Peer endpoints combine their own private keys with each other’s public keys to derive a matching shared secret.

Operations Comparison Matrix

Objective Public Key Action Private Key Action Standard Protocol Primary Output
Confidentiality (RSA-OAEP direct; HPKE hybrid) Encrypts payload (RSA-OAEP) / KEM encapsulation (HPKE) Decrypts payload (RSA-OAEP) / KEM decapsulation (HPKE) RSA-OAEP; RFC 9180 HPKE = KEM + KDF + AEAD Unreadable ciphertext; in HPKE the KEM encapsulates a shared secret (not a pre-existing symmetric key) using the public key, a KDF derives the AEAD key/nonce from that secret, and the AEAD cipher encrypts the actual payload
Integrity & Authenticity Verifies signature tag Generates digital signature tag Ed25519 (RFC 8032), RSA-PSS, ECDSA Evidence that the signature validates for the data under a public key; signer attribution requires trusted key binding and custody evidence
Key Agreement Exchanged with peer Combined with peer public key Ephemeral ECDH (X25519 / NIST P-256) Raw shared-secret material — not yet a usable key; passed through a KDF (see Key Exchange & Derivation page) to derive the actual symmetric AEAD traffic key

Can I Use a Private Key to Encrypt Data?

Not in any standardized or secure sense. No conforming asymmetric encryption scheme — RSA-OAEP, HPKE, ECIES — defines “encrypt with the private key” as an operation at all; standardized encryption APIs simply don’t expose a private-key-encryption call to make.

A Private Key is used for Digital Signing (and for decrypting incoming data locked under its matching public key). The popular shorthand “signing is encrypting with the private key” is an understandable simplification: for raw/textbook RSA specifically, generating a signature (m^d mod n) and decrypting ciphertext (c^d mod n) really are the same modular-exponentiation primitive with the key roles swapped — PKCS#1 / RFC 8017 names these RSASP1 and RSADP, and they’re defined identically. But treating a signature as “ciphertext” is still inaccurate for three reasons:

  1. Signatures Leave Plaintext Intact: Digital signing computes a separate signature tag file (payload.sig) over a message digest while leaving the original payload file (payload.txt) completely unencrypted and readable in cleartext.
  2. Standardized Padding Differs and Isn’t Interchangeable: RSA-OAEP (encryption) and RSA-PSS / PKCS#1v1.5 (signing) wrap that shared modular-exponentiation primitive in different, non-interchangeable padding schemes. A valid signature is not a valid OAEP ciphertext: RSA-PSS/PKCS#1v1.5 signature verification is a public-key operation, while RSA-OAEP decryption — which does use the private key, applying RSADP followed by OAEP decoding and padding validation (RFC 8017) — is a different operation over a different padding scheme; treating one as a substitute for the other fails.
  3. Most Modern Signature Schemes Have No Encryption Primitive at All: Ed25519, ECDSA, and FIPS 204 ML-DSA are not built from an invertible trapdoor function the way RSA is — there is no “decrypt” operation that recovers anything from one of their signatures, so the RSA-specific shorthand doesn’t generalize to them.

Client-Side Executable RSA Asymmetric Encryption & Digital Signature Playground

Interactive Browser Playground

RSA Asymmetric Key Encryption & Digital Signature Playground

Generate real 2048-bit RSA key pairs directly in your browser. Interactively test RSA-OAEP public key encryption, private key decryption, and digital signature verification (Zero server calls / Executed locally via Web Crypto API).

Status: Keys generated on page load via Web Crypto API.
The displayed PEM values belong to the RSA-OAEP encryption keypair. The demo separately generates an RSA-PSS signing keypair for the signature controls; that signing public key is not displayed here.

Demonstrating that signing produces a verification value without encrypting the original payload.

Comparative Analysis: RSA vs Elliptic Curve Cryptography (ECC)

To achieve a given Symmetric Security Strength (measured in bits of brute-force work), asymmetric algorithm key sizes scale at drastically different rates. The bit-strength values and required key sizes below come from NIST SP 800-57 Part 1 Rev. 5; the parenthetical labels (“Legacy Minimum,” “Current Standard,” “High Security,” “Maximum Strength”) are this page’s own descriptive shorthand for how each tier is commonly treated in practice, not terminology NIST itself uses:

Target Security Strength (NIST SP 800-57) Required RSA Key Size (Prime Factorization) Required ECC Key Size (Elliptic Curve Discrete Log) Key Size Efficiency & Guidance
112-bit Security (Legacy Minimum) 2,048 bits 224 bits ECC key is ~9x smaller than RSA. Legacy minimum strength.
128-bit Security (Current Standard) 3,072 bits 256 bits (Curve25519 / P-256) ECC key is 12x smaller than RSA. Standard for web TLS/SSL.
192-bit Security (High Security) 7,680 bits (Sub-Exponential Spike!) 384 bits (P-384) ECC key is 20x smaller than RSA. RSA-7680 causes severe CPU overhead.
256-bit Security (Maximum Strength) 15,360 bits 521 bits (P-521) ECC key is ~29x smaller than RSA. RSA-15360 is generally impractical for production TLS.
Comparison chart comparing RSA and ECC key sizes in bits across 112-bit, 128-bit, 192-bit, and 256-bit security strengths. RSA key sizes grow sub-exponentially while ECC key sizes scale compactly.

Comparison of required RSA vs. ECC key lengths in bits across NIST security strength levels (112-bit to 256-bit security)

Why RSA Key Sizes Grow Much Faster Than ECC

  1. Security Strength Scaling: The chart compares the required key lengths in bits to achieve equivalent NIST symmetric security levels.
  2. Sub-Exponential Attacks on RSA: General Number Field Sieve (GNFS) algorithms allow attackers to factor RSA primes faster than pure brute-force. GNFS runs in sub-exponential time — faster than exponential, but slower than any polynomial — so counteracting it requires RSA key sizes to grow sub-exponentially with the target security level (2,048 bits → 3,072 bits → 7,680 bits → 15,360 bits). This growth is not literally “exponential,” but it is still far steeper than ECC’s scaling.
  3. Linear Scaling of ECC: For appropriately selected curves such as those in NIST SP 800-186, there is no known general-purpose classical sub-exponential attack against Elliptic Curve Discrete Logarithms (ECDLP) — the best known generic attack (Pollard’s rho) costs roughly 2n/2 for an n-bit curve group, so security strength scales roughly linearly with curve size, at about half the curve’s bit length. This reflects the current state of cryptanalysis, not a proof that no future or curve-specific algorithm exists. It is the mental model behind the table above (224 → 256 → 384 → 521 bits); the specific NIST-approved curve sizes are discrete parameter choices dictated by NIST SP 800-57 Part 1 Rev. 5’s strength ranges, not an exact doubling sequence.
  4. Engineering Consequence: At 192-bit security, RSA requires a 7,680-bit key, compared with a compact 384-bit ECC key. Large RSA private-key operations such as signing or decryption therefore incur substantially more CPU and bandwidth overhead than the corresponding ECC operations; the exact difference depends on the operation, implementation, and hardware.

Why Ed25519 (EdDSA) is Preferred for Modern Applications

Specified in RFC 8032, Ed25519 offers major advantages over legacy ECDSA:

Public-Key Input Validation: Why Accepting a Key Isn’t Enough

Asymmetric protocols must validate peer-supplied key material before using it, not just successfully parse its encoding — several well-known attack classes exploit implementations that skip this step:

What I need to remember

Private keys sign, decrypt, decapsulate, or contribute to key agreement; standardized signing is not "encryption with the private key." RSA-OAEP directly encrypts only short payloads, while HPKE is a standardized hybrid construction that uses the recipient's public key to derive or encapsulate key material and AEAD to encrypt the payload.

Primary references