PKI encryption and decryption process
The first is signature, which is encrypted with private key and decrypted by public key.
The second is encryption, which is encrypted with public key and decrypted by private key.
If A wants to send B a secure and confidential data, then AB should each have a private key. A first encrypts the data with B's public key, and then encrypts the encrypted data with its own private key. Finally, it is sent to B to ensure that the content will not be read or tampered with.
1. An encrypts data with B's public key-encryption
2. An encrypts the encrypted data with its own private key-signature
3. B decrypts with A's public key-- verifies the signature
4. B decrypt data with your own private key-decryption