Incryptography, theElGamal encryption system is apublic-key encryption algorithm based on theDiffie–Hellman key exchange. It was described byTaher Elgamal in 1985.[1] ElGamal encryption is used in the freeGNU Privacy Guard software, recent versions ofPGP, and othercryptosystems. TheDigital Signature Algorithm (DSA) is a variant of theElGamal signature scheme, which should not be confused with ElGamal encryption.
ElGamal encryption can be defined over anycyclic group, likemultiplicative group of integers modulo n if and only ifn is 1, 2, 4,pk or 2pk, wherep is an odd prime andk > 0. Its security depends upon the difficulty of theDecisional Diffie Hellman Problem in.
The algorithm first performs Diffie–Hellman key agreement to establish a shared secret, then uses this as aone-time pad for encrypting the message. ElGamal encryption is performed in three phases: the key generation, the encryption, and the decryption. The first is purely key exchange, whereas the latter two mix key exchange computations with message computations.
The first party, Alice, generates a key pair as follows:
A second party, Bob, encrypts a message to Alice under her public key as follows:
Note that if one knows both the ciphertext and the plaintext, one can easily find the shared secret, since. Therefore, a new and hence a new is generated for every message to improve security. For this reason, is also called anephemeral key.
Alice decrypts a ciphertext with her private key as follows:
Like most public key systems, the ElGamal cryptosystem is usually used as part of ahybrid cryptosystem, where the message itself is encrypted using a symmetric cryptosystem, and ElGamal is then used to encrypt only the symmetric key. This is because asymmetric cryptosystems like ElGamal are usually slower than symmetric ones for the samelevel of security, so it is faster to encrypt the message, which can be arbitrarily large, with a symmetric cipher, and then use ElGamal only to encrypt the symmetric key, which usually is quite small compared to the size of the message.
The security of the ElGamal scheme depends on the properties of the underlying group as well as any padding scheme used on the messages. If thecomputational Diffie–Hellman assumption (CDH) holds in the underlying cyclic group, then the encryption function isone-way.[2]
If thedecisional Diffie–Hellman assumption (DDH) holds in, thenElGamal achievessemantic security.[2][3] Semantic security is not implied by the computational Diffie–Hellman assumption alone. SeeDecisional Diffie–Hellman assumption for a discussion of groups where the assumption is believed to hold.
ElGamal encryption is unconditionallymalleable, and therefore is not secure underchosen ciphertext attack. For example, given an encryption of some (possibly unknown) message, one can easily construct a valid encryption of the message.
To achieve chosen-ciphertext security, the scheme must be further modified, or an appropriate padding scheme must be used. Depending on the modification, the DDH assumption may or may not be necessary.
Other schemes related to ElGamal which achieve security against chosen ciphertext attacks have also been proposed. TheCramer–Shoup cryptosystem is secure under chosen ciphertext attack assuming DDH holds for. Its proof does not use therandom oracle model. Another proposed scheme isDHIES,[4] whose proof requires an assumption that is stronger than the DDH assumption.
ElGamal encryption isprobabilistic, meaning that a singleplaintext can be encrypted to many possible ciphertexts, with the consequence that a general ElGamal encryption produces a 1:2 expansion in size from plaintext to ciphertext.
Encryption under ElGamal requires twoexponentiations; however, these exponentiations are independent of the message and can be computed ahead of time if needed. Decryption requires one exponentiation and one computation of a group inverse, which can, however, be easily combined into just one exponentiation.