What Is a Public Key? Cryptography and Secure Communication Explained
A public key is the non-secret half of a cryptographic key pair in public-key cryptography (also called asymmetric cryptography). It is designed to be distributed openly — posted on websites, embedded in certificates, emailed to colleagues — while a matching private key stays confidential on your device or in a hardware security module. Together they enable encrypted communication, digital signatures, and passwordless authentication without both parties sharing the same secret password in advance.
If someone encrypts data with your public key, only your private key can decrypt it. If you sign a message with your private key, anyone with your public key can verify you signed it. That mathematical one-way relationship underpins HTTPS, SSH, PGP email, cryptocurrency wallets, and modern passkeys.
What It Is
Public-key systems rely on hard mathematical problems — factoring large numbers (RSA), elliptic curve discrete logarithm (ECDSA, Ed25519) — where computing forward is feasible but reversing without the private key is computationally infeasible at proper key sizes.
Key pair generation
Software generates private key first, then derives public key from it. You never reconstruct the private key from the public key — that asymmetry is the security foundation.
Common algorithms today
| Algorithm | Typical use |
|-----------|-------------|
| RSA 2048+ | Legacy TLS certificates, some document signing |
| ECDSA P-256 | TLS, Bitcoin addresses historically |
| Ed25519 | Modern SSH keys, Signal, many new systems |
| X25519 | Key exchange in modern protocols |
Shorter elliptic curve keys offer similar strength to much longer RSA keys.
Public key formats
Keys appear as PEM text blocks (BEGIN PUBLIC KEY), SSH one-line strings (ssh-ed25519 AAAA...), QR codes for mobile crypto wallets, or inside X.509 certificates binding a key to a domain name.
What Public Keys Do
Encryption (confidentiality)
Sender finds recipient's public key, encrypts message — only recipient's private key decrypts. Used in PGP email and hybrid TLS handshakes (public key encrypts a symmetric session key for speed).
Digital signatures (integrity and authenticity)
Signer uses private key to sign; verifier uses public key to confirm content unchanged and signer holds private key. Software updates and legal documents use this.
Key exchange
Diffie-Hellman and ECDH let two parties agree on a shared secret over an insecure channel — each contributes public values; eavesdroppers cannot derive the secret easily.
Authentication
Server presents public key or certificate; client proves possession of private key without transmitting it — SSH login, mutual TLS, WebAuthn passkeys.
Common Examples
| Scenario | Public key role |
|----------|-----------------|
| HTTPS website | Browser verifies server's TLS certificate contains trusted public key for example.com |
| GitHub SSH clone | Your public key in account settings; server challenges; client signs with private key |
| PGP encrypted email | Publish public key on keyserver; correspondents encrypt to it |
| Bitcoin wallet | Public address derived from public key receives funds; private key spends |
| Code signing | Vendor signs releases; OS verifies with vendor's embedded public key |
Public Key Infrastructure (PKI)
Certificates issued by certificate authorities (CAs) bind public keys to identities — domain names, organizations. Your browser trusts a root CA store; forged certificates break trust chains (supply chain attacks are high severity).
Self-signed certificates use public keys without CA vouching — fine for labs, risky for public websites unless you manually trust them.
Common Misconceptions
"Public keys must stay secret"
Only private keys are secret. Public keys are meant to be public. Publishing your SSH public key on GitHub is normal. Leaking a private key is catastrophic.
"Public key encryption secures entire web sessions alone"
TLS uses hybrid encryption — asymmetric crypto establishes a symmetric session key (AES) for bulk data because pure public-key encryption is slower.
"Longer public key always displayed means more security"
Display encoding (Base64 length) reflects algorithm and parameters, not a simple "bigger string = better" rule. Ed25519 public keys are short yet strong.
"If I have someone's public key, I can impersonate them"
You can encrypt to them or verify their signatures — you cannot sign as them without their private key.
"Public keys expire like passwords"
Certificates expire; raw public keys do not unless rotation policy replaces them. Calendar-based cert renewal prevents stale CA vouching.
"Blockchain public keys are anonymous"
Pseudonymous — addresses link to public keys on public ledgers; chain analysis and KYC exchanges can deanonymize activity.
FAQ
Can I share my public key by email? Yes — that is standard for PGP and SSH onboarding. Verify fingerprints through a second channel to prevent man-in-the-middle substitution.
What happens if my public key is changed on a server? SSH warns host key changed — could be legitimate rebuild or attack. Investigate before accepting.
Is a password a public key? No. Passwords are shared secrets (symmetric knowledge). Public-key systems split shareable and secret mathematically linked halves.
How do I generate a key pair? Tools like ssh-keygen, GnuPG, OpenSSL, or OS passkey enrollment — always protect private keys with passphrases or hardware tokens.
Are public keys quantum-safe? Current widely deployed algorithms (RSA, ECC) are vulnerable to future large quantum computers. Post-quantum cryptography standards are emerging for migration planning.
The Takeaway
A public key is the openly shareable part of an asymmetric key pair used for encryption to you, signature verification from you, and authentication without password transmission. Its power depends on private key secrecy and trustworthy binding to real identities through certificates or verified fingerprints. Public-key cryptography enables much of modern internet security — from padlock icons to developer SSH access.
---
*This article is general technology education for informational purposes and does not constitute professional cybersecurity advice.*