3.3. Modular Arithmetic, Rsa Algorithm 52
3.3. Modular Arithmetic, Rsa Algorithm 52
1. a ≡ b (mod m).
2. a = b + km for some integer k.
3. a and b have the same remainder when divided by m.
As an example, tables 3.3.1 and 3.3.2 show the addition and multi-
plication tables for Z5 and Z6 respectively.
+ 0 1 2 3 4 · 0 1 2 3 4
0 0 1 2 3 4 0 0 0 0 0 0
1 1 2 3 4 0 1 0 1 2 3 4
2 2 3 4 0 1 2 0 2 4 1 3
3 3 4 0 1 2 3 0 3 1 4 2
4 4 0 1 2 3 4 0 4 3 2 1
Table 3.3.1. Operational tables for Z5
+ 0 1 2 3 4 5 · 0 1 2 3 4 5
0 0 1 2 3 4 5 0 0 0 0 0 0 0
1 1 2 3 4 5 0 1 0 1 2 3 4 5
2 2 3 4 5 0 1 2 0 2 4 0 2 4
3 3 4 5 0 1 2 3 0 3 0 3 0 3
4 4 5 0 1 2 3 4 0 4 2 0 4 2
5 5 0 1 2 3 4 5 0 5 4 3 2 1
Table 3.3.2. Operational tables for Z6
Z∗2 = {1}
Z∗3 = {1, 2}
Z∗4 = {1, 3}
Z∗5 = {1, 2, 3, 4}
Z∗6 = {1, 5}
Z∗7 = {1, 2, 3, 4, 5, 6}
Z8∗ = {1, 3, 5, 7}
Z9∗ = {1, 2, 4, 5, 7, 8}
64 = 3 · 17 + 13 → r = 13
17 = 1 · 13 + 4 → r =4
13 = 3·4+1 → r =1
4 = 4·1+0 → r =0
1 = 13 − 3 · 4 = 13 − 3 · (17 − 1 · 13) = 4 · 13 − 3 · 17
= 4 · (64 − 3 · 17) − 3 · 17 = 4 · 64 − 15 · 17 .
Hence (−15) · 17 ≡ 1 (mod 64), but −15 ≡ 49 (mod 64), so the in-
verse of 17 in (Z∗64 , ·) is 49. We will denote this by writing 17−1 = 49
(mod 64), or 17−1 mod 64 = 49.
3.3. MODULAR ARITHMETIC, RSA ALGORITHM 55
For instance
φ(15) = φ(3 · 5) = φ(3) · φ(5) = (3 − 1) · (5 − 1) = 2 · 4 = 8 .
3. The public encryption key will be the pair (n, e). The private
decryption key will be the pair (n, d). The encryption key is
given to everybody, while the decryption key is kept secret by
the future recipient of the message.
4. The message to be encrypted is divided into small pieces, and
each piece is encoded numerically as a positive integer m smaller
than n.
5. The number me is reduced modulo n; m0 = me mod n.