Multiplicative Inverses
Introduction
Every real number x x x has a multiplicative inverse (except x = 0 x = 0 x = 0 ).
y = 1 x x y = 1 y = \dfrac{1}{x} \qquad xy = 1
y = x 1 x y = 1
For x m o d m x \bmod m x m o d m we wish to find y m o d m y \bmod m y m o d m such that:
x y = 1 , ( m o d , m ) xy = 1 \\, (\bmod \\, m)
x y = 1 , ( m o d , m )
For example, if x = 8 , m = 15 x = 8, m = 15 x = 8 , m = 1 5 then 2 x = 16 ≡ 1 , ( m o d , m ) 2x = 16 \equiv 1 \\, (\bmod \\, m) 2 x = 1 6 ≡ 1 , ( m o d , m ) . So 2 is a multiplicative inverse of 8.
Some combinations of x x x and m m m do not have a multiplicative inverse mod m m m .
The multiplicative inverse is calculated using the extended Euclidean algorithm.
Chinese remainder theorem
Let m 1 , m 2 , . . . , m n m_1, m_2, ... , m_n m 1 , m 2 , . . . , m n be pairwise coprime positive integers greater than 1 and a 1 , a 2 , . . . , a n {a_1, a_2, ... , a_n} a 1 , a 2 , . . . , a n be arbitrary integers. Then the system:
x ≡ a 1 ( m o d , m 1 ) x ≡ a 2 ( m o d , m 2 ) ⋮ x ≡ a n ( m o d , m n ) x \equiv a_1 (\bmod \\, m_1) \\\\
x \equiv a_2 (\bmod \\, m_2) \\\\
\vdots \\\\
x \equiv a_n (\bmod \\, m_n)
x ≡ a 1 ( m o d , m 1 ) x ≡ a 2 ( m o d , m 2 ) ⋮ x ≡ a n ( m o d , m n )
Can be solved by:
x = ( a 1 M 1 y 1 + . . . + a n M n y n ) m o d m x = (a_1M_1y_1 + ... + a_nM_ny_n) \bmod m
x = ( a 1 M 1 y 1 + . . . + a n M n y n ) m o d m
Where:
m = m 1 m 2 . . . m n m = m_1m_2 ... m_n m = m 1 m 2 . . . m n
M i = m m i M_i = \dfrac{m}{m_i} M i = m i m
y i y_i y i is a multiplicative inverse of M i M_i M i
Fermat’s little theorem
If p p p is prime and p p p is not a factor of a a a then a p − 1 ≡ 1 , ( m o d , p ) a^{p-1} \equiv 1 \\, (\bmod \\, p) a p − 1 ≡ 1 , ( m o d , p ) . From this we can extrapolate that for every interger a a a we have a p ≡ a , ( m o d , p ) a^p \equiv a \\, (\bmod \\, p) a p ≡ a , ( m o d , p ) .
gcd ( p , a ) = 1 \text{gcd}(p,a) = 1 gcd ( p , a ) = 1 since a a a has a unique prime decomposition that does not include p p p .
For example, find 7 222 m o d 11 7^{222} \bmod 11 7 2 2 2 m o d 1 1
a p − 1 ≡ 1 m o d p 7 11 − 1 ≡ 1 m o d 11 7 10 ≡ 1 m o d 11 7 222 = ( 7 10 ) 22 ⋅ 7 2 ≡ ( 1 ) 22 ⋅ 49 m o d 11 ≡ 5 m o d 11 7 222 m o d 11 = 5 \begin{aligned}
a^{p-1} &\equiv 1 \bmod p \\\\
7^{11-1} &\equiv 1 \bmod 11 \\\\
7^{10} &\equiv 1 \bmod 11 \\\\
7^{222} &= (7^{10})^{22} \cdot 7^2 \\\\
&\equiv (1)^{22} \cdot 49 \bmod 11 \\\\
&\equiv 5 \bmod 11 \\\\
7^{222} \bmod 11 &= 5
\end{aligned}
a p − 1 7 1 1 − 1 7 1 0 7 2 2 2 7 2 2 2 m o d 1 1 ≡ 1 m o d p ≡ 1 m o d 1 1 ≡ 1 m o d 1 1 = ( 7 1 0 ) 2 2 ⋅ 7 2 ≡ ( 1 ) 2 2 ⋅ 4 9 m o d 1 1 ≡ 5 m o d 1 1 = 5
Private key cryptography
Encryption is a helpful way to send secret messages. Sending a message M M M with a private key E n En E n applied to it and an inverse D e De D e allows the recipient to decrypt it.
D e ( E n ( M ) ) = M De ( En (M) ) = M
D e ( E n ( M ) ) = M
This message could be decrypted by a third party.
Public key cryptography
A message could be made more secure by simply sending it encrypted without the key to decrypt it. It would be very difficult for anyone to compute D e De D e if they are only given E n ( M ) En(M) E n ( M ) .
RSA cryptosystem
In this method, you choose two distinct primes p p p and q q q . Let n = p q n = pq n = p q and k = ( p − 1 ) ( q − 1 ) k = (p-1)(q-1) k = ( p − 1 ) ( q − 1 ) . Then choose an integer e e e where 1 < e < k 1 \lt e \lt k 1 < e < k and gcd ( e , k ) = 1 \text{gcd}(e,k) = 1 gcd ( e , k ) = 1 . ( n , e ) (n,e) ( n , e ) is released as the public key. Let d d d be the multiplicative inverse of e m o d k e \bmod k e m o d k , so d e ≡ 1 m o d k de \equiv 1 \bmod k d e ≡ 1 m o d k . ( n , d ) (n,d) ( n , d ) is the private key, kept secret.