A public key is like an address others can send funds to; a private key is the secret that proves ownership and authorizes spending from that address. Together they form the cryptographic pair that secures every wallet, and they are the foundation of how any crypto wallet works. Bitcoin.org describes the same key pair from the protocol's side.
Definitions
A public key (or the address derived from it) can be shared freely. It's how others send you funds. A private key must never be shared; it's what actually signs and authorizes transactions.
The word "key" is misleading enough to be worth correcting early. Neither key unlocks anything, and nothing is stored behind a lock. Both are simply very large numbers, related by mathematics, and what the private key does is produce signatures. Your coins are not in your wallet; they are entries on a public ledger, and the private key is the only thing that can produce the proof required to move them.
A simple analogy
Think of a public key like a mailbox address anyone can use to send you mail, and the private key like the only key that opens that mailbox. Anyone can drop something in; only the key holder can take it out.
A closer analogy is a signature rather than a lock. Your public key is like a specimen signature filed publicly, so anyone can check that a signature matches it. Your private key is the hand that produces it, and it is one nobody can forge. When you spend, you are not opening anything; you are signing a message saying "move this," and the network verifies the signature against the public key already on record.
Which explains a property that surprises people: signing proves you hold the key without ever revealing it. Every transaction you have ever made is public, complete with its signature, and none of them leak anything about the key that produced them. You can prove ownership a thousand times and be no closer to being compromised.
How they pair
Wallet software generates a private key first, then mathematically derives a matching public key from it. The math works only one direction: you can get the public key from the private key, but not the reverse, which is what keeps the private key secure even though the public key is visible to everyone.
One-way is doing a lot of work in that sentence, and it is fair to ask why anyone believes it. The operation is easy to perform and infeasible to reverse, in the same way that multiplying two large primes is trivial while factoring the result is not. Reversing it is not forbidden, merely astronomically expensive: the number of possible private keys is comparable to the number of atoms in the observable universe, and no amount of computing power brings that within reach by brute force.
Which is why your key's security rests on randomness rather than secrecy of method. The algorithms are public and thoroughly studied. What protects you is that your particular number was picked at random from an unimaginably large space, and this is exactly why generating a wallet with a poor source of randomness, or from a phrase you invented yourself, is catastrophic: predictable keys have been drained within seconds of being funded, by bots that watch for them.
Security
Your private key is ultimately generated from, and recoverable through, your seed phrase. Our guide to seed phrases explains how that backup system works. Protecting the private key, directly or via the seed phrase, is the single most important security task in crypto.
In practice you will rarely see your private key at all, and that is by design. Modern wallets derive a whole tree of keys from your seed phrase, one per address, so the phrase is the thing you back up and the individual keys stay out of sight. This is why the seed phrase, not the key, is what scammers ask for: it is the root that regenerates everything below it.
The consequence to sit with is that key security is binary. There is no partially compromised key, no reduced access, no damage limitation. Whoever holds it has exactly the same power over your funds as you do, forever, and the network cannot tell the difference between you and them, because there is no difference. It is not checking who you are. It is checking whether the signature is valid.
One clarification that trips people up: your address is not your public key, though the two are related. The address is a shortened, hashed version of the public key, which is what makes it a manageable string rather than an unwieldy number. Sharing it is entirely safe. It reveals your balance and history to anyone who looks, since the ledger is public, but it gives away nothing that helps anyone spend your funds.