ElGamal encryption
The ElGamal algorithm is an asymmetric key encryption algorithm for public key cryptography which is based on Diffie-Hellman key agreement. It was described by Taher Elgamal in 1984. The ElGamal algorithm is used in the free GNU Privacy Guard software, recent versions of PGP, and other cryptosystems. The Digital Signature Algorithm is a variant of the ElGamal signature scheme, which should not be confused with the ElGamal algorithm.
ElGamal can be defined over any cyclic group . Its security depends upon the difficulty of a certain problem in related to computing discrete logarithms (see below).
The algorithm
ElGamal consists of three components: the key generator, the encryption algorithm, and the decryption algorithm.
The key generator works as follows:
- Alice generates an efficient description of a cyclic group of order with generator . See below for specific examples of how this can be done.
- Alice chooses a random from .
- Alice computes .
- Alice publishes , along with the description of , as her public key. Alice retains as her private key which must be kept secret.
The encryption algorithm works as follows: to encrypt a message to Alice under her public key ,
- Bob converts into an element of .
- Bob chooses a random from , then calculates and .
- Bob sends the ciphertext to Alice.
The decryption algorithm works as follows: to decrypt a ciphertext with her private key ,
- Alice computes as the plaintext message.
The decryption algorithm produces the intended message, since
If the space of possible messages is larger than the size of , then the message can be split into several pieces and each piece can be encrypted independently. Typically, however, a short key to a symmetric-key cipher is first encrypted under ElGamal, and the (much longer) intended message is encrypted more efficiently using the symmetric-key cipher — this is termed hybrid encryption.
Security
ElGamal is a simple example of a semantically secure asymmetric key encryption algorithm (under reasonable assumptions). It is probabilistic, meaning that a single plaintext can be encrypted to many possible ciphertexts, with the consequence that a general ElGamal encryption produces a 2:1 expansion in size from plaintext to ciphertext.
ElGamal's security rests, in part, on the difficulty of solving the discrete logarithm problem in . Specifically, if the discrete logarithm problem could be solved efficiently, then ElGamal would be broken. However, the security of ElGamal actually relies on the so-called Decisional Diffie-Hellman (DDH) assumption. This assumption is often stronger than the discrete log assumption, but is still believed to be true for many classes of groups.
Generating the group G
As described above, ElGamal can be defined over any cyclic group , and is secure if a certain computational assumption (the "DDH Assumption") about that group is true. Unfortunately, the straightforward use of for a prime is insecure, because the DDH Assumption is false in this group[citation needed]. This is despite the fact that computing discrete logs is believed to be hard in . This is not enough for the security of ElGamal.
The two most popular types of groups used in ElGamal are subgroups of and groups defined over certain elliptic curves. Here is one popular way of choosing an appropriate subgroup of which is believed to be secure:
- Choose a random large prime such that for some small integer and large prime . This can be done, for example with , by first choosing a random large prime and checking if is prime.
- Choose a random element such that and , i.e. such that is of order .
- The group is the subgroup of generated by , i.e. the set of th residues mod .
When encrypting, care must be taken to properly encode the message as an element of , and not, say, as just an arbitrary element of .
Efficiency
Encryption under ElGamal requires two exponentiations; however, these exponentiations are independent of the message and can be computed ahead of time if need be. The ciphertext is twice as long as the plaintext, which is a disadvantage as compared to some other algorithms. Decryption only requires one exponentiation (instead of division, exponentiate to ). Unlike in the RSA and Rabin systems, ElGamal decryption cannot be sped up via the Chinese remainder theorem.
Miscellaneous
ElGamal is malleable in an extreme way: for example, given an encryption of some (possibly unknown) message , one can easily construct an encryption of the message . Therefore ElGamal is not secure under chosen ciphertext attack. On the other hand, the Cramer-Shoup system (which is based on ElGamal) is secure under chosen ciphertext attack.
See also
References
- Taher ElGamal, "A Public-Key Cryptosystem and a Signature Scheme Based on Discrete Logarithms", IEEE Transactions on Information Theory, v. IT-31, n. 4, 1985, pp469–472 or CRYPTO 84, pp10–18, Springer-Verlag.
- Handbook of Applied Cryptography, contains a detailed description of ElGamal Algorithm in Chapter 8 (PDF file).