Public-key cryptography uses a mathematically linked key pair, a public key anyone can have and a private key kept secret, for encryption, key exchange and signatures.
In public-key (asymmetric) cryptography each party has two related keys. The public key can be shared freely, and the private key never leaves its owner. This solves the problem of agreeing on a secret with someone you have never met. For key agreement, two parties combine their own private key with the other's public key to arrive at the same shared secret, as in Diffie-Hellman and X25519. For encryption, a sender encrypts a content key to a recipient's public key so only the recipient can open it; modern systems do this through hybrid constructions such as HPKE (RFC 9180) rather than encrypting bulk data directly. For signatures, the private key signs and anyone with the public key can verify, as in Ed25519 or the WebAuthn credentials behind passkeys. Public-key operations are much slower than symmetric ones, so they protect small keys, not large files. The main weakness is trust in the public key: you must be sure it really belongs to the person you intend, which is why systems use verification codes, certificates or key transparency. Quantum computers would break today's RSA and elliptic-curve schemes, which is driving the move to post-quantum algorithms. BotPassword uses public-key envelopes for sharing vault items between people.