Multiplicative Inverses

Introduction

Every real number xx has a multiplicative inverse (except x=0x = 0).

y=1xxy=1y = \dfrac{1}{x} \qquad xy = 1

For xmodmx \bmod m we wish to find ymodmy \bmod m such that:

xy=1,(mod,m)xy = 1 \\, (\bmod \\, m)

For example, if x=8,m=15x = 8, m = 15 then 2x=161,(mod,m)2x = 16 \equiv 1 \\, (\bmod \\, m). So 2 is a multiplicative inverse of 8.

Some combinations of xx and mm do not have a multiplicative inverse mod mm.

The multiplicative inverse is calculated using the extended Euclidean algorithm.

Chinese remainder theorem

Let m1,m2,...,mnm_1, m_2, ... , m_n be pairwise coprime positive integers greater than 1 and a1,a2,...,an{a_1, a_2, ... , a_n} be arbitrary integers. Then the system:

xa1(mod,m1)xa2(mod,m2)xan(mod,mn)x \equiv a_1 (\bmod \\, m_1) \\\\ x \equiv a_2 (\bmod \\, m_2) \\\\ \vdots \\\\ x \equiv a_n (\bmod \\, m_n)

Can be solved by:

x=(a1M1y1+...+anMnyn)modmx = (a_1M_1y_1 + ... + a_nM_ny_n) \bmod m

Where:

m=m1m2...mnm = m_1m_2 ... m_n

Mi=mmiM_i = \dfrac{m}{m_i}

yiy_i is a multiplicative inverse of MiM_i

Fermat’s little theorem

If pp is prime and pp is not a factor of aa then ap11,(mod,p)a^{p-1} \equiv 1 \\, (\bmod \\, p). From this we can extrapolate that for every interger aa we have apa,(mod,p)a^p \equiv a \\, (\bmod \\, p).

gcd(p,a)=1\text{gcd}(p,a) = 1 since aa has a unique prime decomposition that does not include pp.

For example, find 7222mod117^{222} \bmod 11

ap11modp71111mod117101mod117222=(710)2272(1)2249mod115mod117222mod11=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}

Private key cryptography

Encryption is a helpful way to send secret messages. Sending a message MM with a private key EnEn applied to it and an inverse DeDe allows the recipient to decrypt it.

De(En(M))=MDe ( En (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 DeDe if they are only given En(M)En(M).

RSA cryptosystem

In this method, you choose two distinct primes pp and qq. Let n=pqn = pq and k=(p1)(q1)k = (p-1)(q-1). Then choose an integer ee where 1<e<k1 \lt e \lt k and gcd(e,k)=1\text{gcd}(e,k) = 1. (n,e)(n,e) is released as the public key. Let dd be the multiplicative inverse of emodke \bmod k, so de1modkde \equiv 1 \bmod k. (n,d)(n,d) is the private key, kept secret.