ElGamal encryption
From Wikipedia, the free encyclopedia
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 G. Its security depends upon the difficulty of a certain problem in G related to computing discrete logarithms (see below).
Contents |
[edit] 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 G of order q with generator g. See below for specific examples of how this can be done.
- Alice chooses a random x from .
- Alice computes h = gx.
- Alice publishes h, along with the description of G,q,g, as her public key. Alice retains x as her secret key.
The encryption algorithm works as follows: to encrypt a message m to Alice under her public key (G,q,g,h),
- Bob converts m into an element of G.
- Bob chooses a random y from , then calculates c1 = gy and .
- Bob sends the ciphertext (c1,c2) to Alice.
The decryption algorithm works as follows: to decrypt a ciphertext (c1,c2) with her secret key x,
- 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 G, 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.
[edit] 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 G. 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.
[edit] Generating the group G
As described above, ElGamal can be defined over any cyclic group G, and is secure if a certain computational assumption (the "DDH Assumption") about that group is true. Unfortunately, the straightforward use of G = Zp for a prime p is insecure, because the DDH Assumption is false in this group. In contrast, computing discrete logs is believed to be hard in Zp, but this is not enough for the security of ElGamal.
The two most popular types of groups used in ElGamal are subgroups of Zp and groups defined over certain elliptic curves. Here is one popular way of choosing an appropriate subgroup of Zp which is believed to be secure:
- Choose a random large prime p such that p − 1 = kq for some small integer k and large prime q. This can be done, for example with k = 2, by first choosing a random large prime q and checking if p = 2q + 1 is prime.
- Choose a random element such that and gq = 1mod p, i.e. such that g is of order q.
- The group G is the subgroup of Zp generated by g, i.e. the set of kth residues mod p.
When encrypting, care must be taken to properly encode the message m as an element of G, and not, say, as just an arbitrary element of Zp.
[edit] 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 c1 to q − x). Unlike in the RSA and Rabin systems, ElGamal decryption cannot be sped up via the Chinese remainder theorem.
[edit] Miscellaneous
ElGamal is malleable in an extreme way: for example, given an encryption (c1,c2) of some (possibly unknown) message m, one can easily construct an encryption of the message 2m. 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.
[edit] See also
[edit] 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).
Algorithms: Cramer-Shoup | DH | DSA | ECDH | ECDSA | EKE | ElGamal | GMR | IES | Lamport | MQV | NTRUEncrypt | NTRUSign | Paillier | Rabin | Rabin-Williams | RSA | Schnorr | SPEKE | SRP | XTR |
Theory: Discrete logarithm | Elliptic curve cryptography | RSA problem |
Standardization: ANS X9F1 | CRYPTREC | IEEE P1363 | NESSIE | NSA Suite B Misc: Digital signature | Fingerprint | PKI | Web of trust | Key size |
History of cryptography | Cryptanalysis | Cryptography portal | Topics in cryptography |
Symmetric-key algorithm | Block cipher | Stream cipher | Public-key cryptography | Cryptographic hash function | Message authentication code | Random numbers |