Section 4 The Rabin and Paillier cryptosystems
Subsection 4.1 The Rabin cryptosystem
There is an other cryptosystem based on the difficulty of factoring large integers due to Rabin. If \(N=p\cdot q\) is a product of two large primes, then extracting square roots modulo \(N\) is a challenging computational task. The encryption and decryption is similar to the one used in RSA, however in case of the RSA exponent \(e\) we have that \(\gcd(e,\varphi(N))=1.\) Here the exponent is fixed, it is 2. The steps involved in the encryption are as follows.
Alice obtains Bob’s public key: \(N,\)
Alice represents the message as a number \(m\) from the set \(\{0,1,\ldots,N-1\},\)
Alice sends to Bob the value \(c\equiv m^2\pmod{N}.\)
The decryption works as described below.
Bob computes the square root of \(c\) modulo \(N.\)
There are 4 roots, hence it is important to have some redundancy in the message, for example the least significant \(k\) bits of the binary representation of \(m\) are all ones.
The decryption is especially easy if we choose primes \(p\) and \(q\) such that \(p\equiv q\equiv 3\pmod{4}.\) In this case Euler’s criterion provides that
and similarly for \(q\) we get that
Having two square roots modulo \(p\) and other two modulo \(q\) yields four square roots modulo \(N\) by applying the Chinese Reminder Theorem.
Suppose that Bob’s public key is \(N=11\cdot 19=209\) and Alice wants to send the message \(m=79.\) Alice computes
Bob receives \(c=180\) and determines the possible square roots, these are given by
Finally, we determine the solutions of the system of congruences by means of the Chinese Reminder Theorem:
We obtain that
Subsection 4.2 Paillier’s cryptosystem
In 1999 Paillier published an article in which he introduced a cryptosystem based on composite residuosity classes. As in case of the RSA cryptosystem we fix two large primes \(p\) and \(q.\) The public key is given by \((N,g),\) where \(N=p\cdot q\) and \(g\) is an element of \(\mathbb{Z}_{N^2}^*.\) Let us denote by \(\lambda\) the Carmichael function (\(\lambda(p\cdot q)=\lcm(p-1,q-1)\)) and
The element \(g\) has to satisfy that \(\gcd(N,L(g^\lambda\bmod N^2))=1.\) To encrypt a message Alice follows the steps given below.
The message \(m\) is represented as an element of \(\mathbb{Z}_{N},\)
Alice picks a random number \(r\in \mathbb{Z}_{N}^*,\)
-
the ciphertext is in the set \(\mathbb{Z}_{N^2},\) it is computed via the formula
\begin{equation*} c\equiv g^m\cdot r^N\pmod{N^2}. \end{equation*}
Bob can decrypt the ciphertext using his private key \((p,q)\) as follows:
To show that the decryption in fact works we need a theorem of Carmichael.
Carmichael If \(a\) and \(N\) are relatively prime numbers, then
The element \(g\) comes from \(\mathbb{Z}_{N^2}^*,\) so \(g^{\lambda(N)}\equiv 1\pmod{N}.\) Therefore there exists a \(k\in\mathbb{Z}_N\) such that
We also need to compute \(c^{\lambda(N)}\pmod{N^2}.\) Here we obtain
Clearly we have \(\varphi(N^2)=N\varphi(N)=N(p-1)(q-1),\) therefore \(r^{N\lambda(N)}\equiv 1\pmod{N^2}.\) That is we get that
Putting together the above results we have
The remaining part is as follows
Consider an example with \(N=p\cdot q=17\cdot 29=493\) and \(g=35.\) Alice wants to send the message \(m=28\) to Bob and she chooses the random integer \(r=9.\) Alice computes
Bob may decrypt it by evaluating \(L(c^\lambda\bmod N^2)\) and \(L(g^\lambda\bmod N^2).\) He obtains
So it remains to determine
we see that the message is decrypted.
SageMath summary.
- crt()
Applies the Chinese Reminder Theorem.
- lcm()
Returns the least common multiple.
- randint()
Returns a random integer from a range.
- random_prime()
Returns a random prime number from a range.