Score:4

Paillier cryptosystem break with random number

lk flag

In the Paillier cryptosystem we choose $n=p\,q$ where $p$ and $q$ are primes, $g=n+1$, $\lambda=\phi(n)$, $\mu=\lambda^{-1}\bmod n$.

The public key is: $(n,g)$.

The private key is: $(\lambda,\mu)$.

Encryption: choose random $r$ ($0<r<n$), encryption of message $m$ is $c=(g^m)(r^n)\bmod n^2$

Decryption: $m=((c^\lambda\bmod n^2-1)/n)\,\mu\bmod n$.

I am asking: is it possible to decrypt the ciphertext of the Paillier cryptosystem with knowledge of the random number $r$?

fgrieu avatar
ng flag
Welcome to crypto-SE. I reformatted the question [using MathJax](https://crypto.meta.stackexchange.com/a/1070/555). I have _not_ changed to the usual decryption formula: $m=\bigl\lfloor((c^\lambda\bmod n^2)-1)/n\bigr\rfloor\,\mu\bmod n$, nor added the usual additional requirements $p\ne q$ and $p<2q<4p$. You can of course [edit](https://crypto.stackexchange.com/posts/104044/edit) the question, perhaps adding where you are stuck.
fgrieu avatar
ng flag
Is that homework? That would make the question off-[topic](https://crypto.stackexchange.com/help/on-topic) unless effort to solve the problem is shown in the question. For now I'll only give hints: with $r$ known, what remains unknown in the equation $c=(g^m)(r^n)\bmod n^2$ ? Work that out using the [binomial theorem](https://en.wikipedia.org/wiki/Binomial_theorem) and elementary properties of$\bmod$.
legends_never_die avatar
lk flag
I've reached this point: c = (nm+1) % (n**2) + (r**n) % (n**2). what should i do next?
fgrieu avatar
ng flag
First, fix it; where did the second + creep in? Next, try to isolate the one unknown. Hint: almost all integers have a multiplicative inverse modulo $n^2$, and it can be efficiently computed, e.g. by the [(half) extended Euclidean algorithm](https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm#Modular_integers). Note: MathJax mostly works in comment too, e.g. $c=(g^m)(r^n)\bmod n^2$ is written `$c=(g^m)(r^n)\bmod n^2$`.
poncho avatar
my flag
I would disagree with fgrieu's suggestion of using the binomial theorem - instead, from $(g^m)(r^n) \bmod n^2$ and $r$, first find $g^m \bmod n^2$; once you got there, what can you say about that?
fgrieu avatar
ng flag
@poncho: I wrote my [proof using the binomial theorem](https://crypto.stackexchange.com/a/104310/555). I scratch my head for another argument that $(n+1)^m\equiv m\,n+1\bmod{n^2}$, or another proof altogether, but nothing happens.
Score:2
cn flag

Once you know $r$, you can remove it from the ciphertext. If $c=(1+n)^m\bmod n^2$ then $m=(c-1)/n\mod n.$

Score:2
ng flag

Yes, it would be possible to decrypt the ciphertext of the Paillier cryptosystem if the random number $r$ leaked.

Encryption if per $c=(g^m)(r^n)\bmod n^2$. We know that $g=n+1$. Thus $c=((n+1)^m)(r^n)\bmod n^2$. By the binomial theorem, $$(n+1)^m=\sum_{k=0}^m\binom n k n^k$$ and $n^k\bmod n^2=0$ when $k>1$. Therefore, $(n+1)^m\bmod n^2$ reduces to $m\,n+1\bmod n^2$, and we get $c=(m\,n+1)(r^n)\bmod n^2$.

Knowing $r$, and $n$ being public, we can computes $s=r^{-1}\bmod n$, e.g. by the (half) extended Euclidean algorithm. We can then compute $t=s^n\,c\bmod n^2$ which is such that $t=m\,n+1\bmod n^2$.

And then, since $0\le m<n$, we can compute $m$ as $(t-1)/n$.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.