The publicKey must be revealed before the wallet can inject an operation to the blockchain. The client (and most wallets) will automatically add a reveal operation onto the first operation you try to perform with the new address. E.g. sending xtz or an fa1.2/fa2 token, delegating to a baker or originating a contract, will all trigger a reveal operation first
In the contract, you cannot obtain the public key from an address but if you are given both the public key and the address you can check that the public key corresponds to the address. In Michelson, assuming you have the address and the public key at the top of your stack this is done with HASH_KEY; IMPLICIT_ACCOUNT; ADDRESS; COMPARE; EQ.
In the client, you ...
It is not possible to do from inside a contract. But you can use the following RPC:
For implicit accounts, the address is nothing more than the hash of the public key so this means that you can compute the address from the public key but not the other way around.
In Michelson, you have:
HASH_KEY : key -> key_hash
IMPLICIT_ACCOUNT : key_hash -> contract unit
ADDRESS : contract _ -> address
I don't understand how I would apply this ...