ElGamal encryption

In cryptography, the ElGamal encryption system is an asymmetric key encryption algorithm for public-key cryptography which is based on the Diffie–Hellman key exchange. The system provides an additional layer of security by asymmetrically encrypting keys previously used for symmetric message encryption. It was described by Taher Elgamal in 1985.[1] ElGamal encryption is used in the free GNU Privacy Guard software, recent versions of PGP, and other cryptosystems. The Digital Signature Algorithm (DSA) is a variant of the ElGamal signature scheme, which should not be confused with ElGamal encryption.

ElGamal encryption 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 encryption consists of three components: the key generator, the encryption algorithm, and the decryption algorithm.

Key generation

The key generator works as follows:

  • Alice generates an efficient description of a cyclic group of order with generator . See below for a discussion on the required properties of this group.
  • Alice chooses an randomly 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 chooses a random from , then calculates .
  • Bob calculates the shared secret .
  • Bob maps his message onto an element of .
  • Bob calculates .
  • Bob sends the ciphertext to Alice.

Note that one can easily find if one knows . Therefore, a new is generated for every message to improve security. For this reason, is also called an ephemeral key.


The decryption algorithm works as follows: to decrypt a ciphertext with her private key ,

  • Alice calculates the shared secret
  • and then computes which she then converts back into the plaintext message , where is the inverse of in the group . (E.g. modular multiplicative inverse if is a subgroup of a multiplicative group of integers modulo n).
The decryption algorithm produces the intended message, since

Practical use

The ElGamal cryptosystem is usually used in a hybrid cryptosystem. I.e., the message itself is encrypted using a symmetric cryptosystem and ElGamal is then used to encrypt the key used for the symmetric cryptosystem. This is because asymmetric cryptosystems like Elgamal are usually slower than symmetric ones for the same level of security, so it is faster to encrypt the symmetric key (which most of the time is quite small if compared to the size of the message) with Elgamal and the message (which can be arbitrarily large) with a symmetric cipher.

Other Languages
العربية: تشفير الجمل
azərbaycanca: El-Qamal sxemi
čeština: ElGamal
español: Cifrado ElGamal
한국어: 엘가말 암호
italiano: ElGamal
日本語: ElGamal暗号
polski: ElGamal
português: El Gamal
suomi: ElGamal
Türkçe: ElGamal
українська: Схема Ель-Гамаля