We don't use public-private keys to encrypt files or documents. We use public-key cryptography for hybrid encryption or digital signatures.
Examples of Hybrid encryption.
RSA as Key Encapsulation Mechanism (KEM)) and AES-GCM as Data Encapsulation Mechanism (DEM). This composition of a KEM and a DEM (data encapsulation mechanism; an authenticated cipher serves as a DEM) provides the standard of IND-CCA2/NM-CCA2—ciphertext indistinguishability and nonmalleability under adaptive chosen-ciphertext attack. That is the minimum requirement for modern Cryptography. See the detail, here
Similarly, one can achieve with Diffie-Hellman key exchange (DHKE). Two-party exchange keys by the DHKE and generate the sessing key by using a Key Derivation Function. And with the derived key, we use a modern mode of operation like AES-GCM or ChaCha20-Poly1305. Both are Authenticated Encryption modes that provide us with Confidentiality, Integrity, and Authentication.
With libsodium you can start to use crypto_box_curve25519xsalsa20poly1305. Based on Elliptic Curver DHKE: Curve X25519, Encryption: XSalsa20 stream cipher, Authentication: Poly1305 MAC.
- Here only warn about the common mistake on RSA. RSA decryption is not signature. RSA signature requires special padding RSA-PSS and using the same RSA setup for encryption and signature is not advised.
It tells almost nothing about the TLS,
According to image 1, for two way communication, each person needs to generate a pair of keys. However according to image 2, only one pair of keys is required for two way communication. Thanks to anyone who can settle my confusion.
Source 2 only talk about public-private key usage. However, there is a misconception there. You don't encrypt with your private key. The sole purpose of encryption is confidentiality. Your public key is public, so everybody can use your public key to decrypt the message encrypted with your private key!
To send an encrypted message to you, you either share a common secret key with the other party - that we don't prefer - or have a private and public key pair. With this pair, once you publish your public key, everybody can send you a message, even anonymously. If you don't want anonymous messages, then the other site must have a public-private key which you know the public key belongs to them. Rest, use a hybrid cryptosystem as above.
The 2. source only talk about in this way, explicitly they are talking the same. Each user at least one public-private key and distribute their public key. Of course, you may need a Certificate Authority to prove the ownership of the public key.