Foundations of Blockchain
上QQ阅读APP看书,第一时间看更新

Encryption and decryption using RSA

Encryption is performed in RSA using the distributed public key. Message M is converted to integer m such that 0 ≤ m < n. Ciphertext c is computed using the exposed public exponent, as follows:

c ≡ me mod (n)

Anyone who possesses the public exponent can perform encryption on the message and transmit it to whoever possesses the private exponent. Whoever has access to the ciphertext and private exponent can perform decryption as follows:

m ≡ cd mod (n)

Message M could be regenerated from the decrypted integer m. This is how RSA makes use of the prime factorization technique to perform encryption and decryption. The process could be performed reasonably quickly for small messages, but it is not the preferred way of encryption for large messages. This is why RSA is widely used in cryptographic primitives, such as digital signatures, rather than encryption.