Introduction to Cryptography

Let p,qZp,q \in \Z be two prime numbers and MZM \in \Z be a postive integer coprime with pqpq. Then M(p1)(q1)(modpq)M^{(p-1)(q-1)} \equiv \pmod{pq}

RSA

A large number nn where it is of the form n=pqn=pq, for two prime numbers p,qp,q. Moreover gcd(e,(p1)(q1))=1(e, (p-1)(q-1)) = 1. ee is known as the public key, which is not a very large number. nn and ee are both shared between parties and made public. Only the owner of nn knows pp and qq. For anybody else, it is impossible to calculate.

Let use consider the case of Eve:
n=2418737527=4861149757=pqn = 2418737527 = 48611 \cdot 49757 = pq

We want to send her the message Salut. The message is therefore represented by the number M=1901122120M = 1901122120

We compute:

CMe(modn)C\equiv M^e \pmod{n}
190112212011(mod2418737527)\equiv 1901122120^{11} \pmod{2418737527}
250061500(mod2418737527)\equiv 250061500 \pmod{2418737527} and we send CC to Eve.

Since Eve knows pp and qq, she also knows dd and tt such that det(p1)(q1)=1d\cdot e - t(p-1)(q-1) = 1. In her case d=159134011d = 159134011 and t=7t = 7. She then computes:

Cd2500615001539134011(mod2418737527))C^d\equiv 250061500^{1539134011} \pmod{2418737527)}
1901122120(mod2418737527)\equiv 1901122120 \pmod{2418737527}
M(mod2418737527)\equiv M \pmod{2418737527}

and the message is discovered! The number dd is called the private key.

In summary, the crypted message is CMe(modn)C \equiv M^e \pmod{n}. When the receiver gets the message they compute Cd(modn)C^d \pmod{n}, and the message is result.