And then if you want to talk to them, you encrypt your message with their Public Key. Then only they can decrypt it with their Private Key (assuming no one else their Private Key).
But if a hacker / NSA agent / script kiddo pretends to be your friend and tells you their Public Key, then they'll be able to decrypt your messages with their Private Key. You might never know that they aren't your friend.
You'll have to ensure that you actually have the Public Key of your friend by some other method. For example meet them in person to exchange Public Keys, or read it out over the phone, if you know what their voice sounds like on the phone.
It could be decentralized through pluggable identity authorities which provide the public key transfer via a secure channel. Essentially you'd use the same protocol and select what servers (WhatsApp, Signal, maybe some sort of immutable ledger elsewhere) to use.
Any time you have a central authority providing that validation, you have to trust that your "friend" hasn't fooled them.
This is much easier to explain to a non-techie than comparing security numbers or hashes.
- Red = No trust
- Yellow = You trust that the server has verified the identity
- Green = You have verified the identity yourself
(Edit: Formatting)
Edit: Found the problem with that. Certificate authorities are supposed to actually go out and confirm that the person who requested the certificate, is the person that they say they are. This is far too much work, if you want to verify each individual person who wants to use a messenger.
I could be wrong though.