Choose two large prime numbers p and q randomly and independently of each other such that. This property is assured if both primes are of equal length.
If using p,q of equivalent length, a simpler variant of the above key generation steps would be to set and, where .
Encryption
Let be a message to be encrypted where
Select random where and
Compute ciphertext as:
Decryption
Let be the ciphertext to decrypt, where
Compute the plaintext message as:
As the original points out, decryption is "essentially one exponentiation modulo."
Homomorphic properties
A notable feature of the Paillier cryptosystem is its homomorphic properties along with its non-deterministic encryption. As the encryption function is additively homomorphic, the following identities can be described:
Homomorphic addition of plaintexts
Homomorphic multiplication of plaintexts
However, given the Paillier encryptions of two messages there is no known way to compute an encryption of the product of these messages without knowing the private key.
Background
Paillier cryptosystem exploits the fact that certain discrete logarithms can be computed easily. For example, by binomial theorem, This indicates that: Therefore, if: then Thus:
The original cryptosystem as shown above does provide semantic security against chosen-plaintext attacks. The ability to successfully distinguish the challenge ciphertext essentially amounts to the ability to decide composite residuosity. The so-called decisional composite residuosity assumption is believed to be intractable. Because of the aforementioned homomorphic properties however, the system is malleable, and therefore does not enjoy the highest echelon of semantic security that protects against adaptive chosen-ciphertext attacks. Usually in cryptography the notion of malleability is not seen as an "advantage," but under certain applications such as secure electronic voting and threshold cryptosystems, this property may indeed be necessary. Paillier and Pointcheval however went on to propose an improved cryptosystem that incorporates the combined hashing of message m with random r. Similar in intent to the Cramer–Shoup cryptosystem, the hashing prevents an attacker, given only c, from being able to change m in a meaningful way. Through this adaptation the improved scheme can be shown to be IND-CCA2 secure in the random oracle model.
Applications
Electronic voting
Semantic security is not the only consideration. There are situations under which malleability may be desirable. The above homomorphic properties can be utilized by secure electronic voting systems. Consider a simple binary vote. Let m voters cast a vote of either 1 or 0. Each voter encrypts their choice before casting their vote. The election official takes the product of the m encrypted votes and then decrypts the result and obtains the value n, which is the sum of all the votes. The election official then knows that n people voted for and m-n people voted against. The role of the random r ensures that two equivalent votes will encrypt to the same value only with negligible likelihood, hence ensuring voter privacy.
Another feature named in paper is the notion of self-blinding. This is the ability to change one ciphertext into another without changing the content of its decryption. This has application to the development of ecash, an effort originally spearheaded by David Chaum. Imagine paying for an item online without the vendor needing to know your credit card number, and hence your identity. The goal in both electronic cash and electronic voting, is to ensure the e-coin is valid, while at the same time not disclosing the identity of the person with whom it is currently associated.