Public key cryptography always works the same way: Encryption is done with the public key, decryption done with the private key. It is not possible to decrypt anything with the public key (otherwise the whole system would crash down). The only time it's done the other way is for message authentication, where only a digest of a message is encrypted and can be verified (not decrypted) using the public key.
Chat with our AI personalities
When you reference a "public key" you are implying that the file has been encrypted using "asymmetric cryptography". In asymmetric cryptography, encryption and decryption depend on a key PAIR. The user retains their private key and publishes their public key. Anyone can encrypt a file using the user's public key and send it to them. The only person who should be able to decrypt a file encrypted with that public key is the holder of the private key - which, unless the user has made the mistake of sharing their private key - means that only the original user can decrypt the messages sent to them. Most of the asymmetric encryption algorithms use pretty much the same method to decrypt that was used to encrypt, but use the "other" key from the key pair. Messages encrypted using the private key can only be decrypted using the public key - which provides some authentication that the message indeed came from the holder of the private key. Messages encrypted using the public key can only be decrypted by the holder of the private key, so messages sent to them should be secure.
This is known as RSA encryption. Encryption involving a public and private key combination is known as asynchronous cryptography, as opposed to synchronous cryptography. It is also known as public key cryptography. RSA is an algorithm that may be used (but there are others that can be used), in public key cryptography. (A key pair)
A public and private key
To decrypt a message using a public key, the recipient must have the corresponding private key. The sender encrypts the message using the recipient's public key, which can only be decrypted with the recipient's private key. This ensures that only the intended recipient can read the message.
This is known as public-key cryptography, or asymmetric cryptography which is used to secure electronic communication over a network.