liveBook · Manning

Modular exponentiation

As explained in Hacking Cryptography

Modular exponentiation is the computation of an integer power followed by reduction modulo a specified integer.

Modular exponentiation raises an integer to a power and reduces the result modulo a specified integer. In RSA, encryption computes c = m^e mod n, while decryption computes m = c^d mod n. section 8.3.2

RSA message recovery

With p = 193, q = 727, n = 140311, e = 17653, and d = 77533, Bob encrypts m = 1337 as c = 1337^17653 mod 140311 = 133682. Alice recovers 1337 by calculating 133682^77533 mod 140311. section 8.3.2

Equation 8.10
\[\begin{aligned} \begin{aligned} c &= \text{Encrypt}(m, \text{PubKey}_{\text{Alice}}) \\ c &= m^e \bmod n \end{aligned} \label{equation:bob-rsa-encrypt} \end{aligned}\]

Shows the RSA encryption equation that applies modular exponentiation to a plaintext using a public key. section 8.3.2

Equation 8.11
\[\begin{aligned} \begin{aligned} m &= \text{Decrypt}(c, \text{PrivKey}_{\text{Alice}}) \\ m &= c^d \bmod n \end{aligned} \label{equation:alice-rsa-decrypt} \end{aligned}\]

Shows the corresponding decryption equation using the private exponent. section 8.3.2

How Hacking Cryptography covers it

How deep it goes
Defines the operation and works through RSA arithmetic, while deferring the proof that decryption succeeds.
Examples
Works through RSA values using primes 193 and 727, plaintext 1337, ciphertext 133682, and modulus 140311.
What it assumes
Assumes familiarity with modular arithmetic, greatest common divisors, and multiplicative inverses.
What you can do after
Apply modular exponentiation to calculate RSA ciphertexts and recover plaintext with the corresponding exponents.
How it connects
Connects modular exponentiation with RSA, Euler's theorem, integer factorization, and the extended Euclidean algorithm.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Hacking Cryptography. The section links point to the parts of the book it draws on.