Skip to content

ElGamal

The ElGamal encryption system is an asymetric cryptographic algorithm. A public key is used to encrypt data and a private key is used to decrypt data.

Textbook definition

The variables of textbook ElGamal are:

VariableDescription
ppA large prime number
ggA generator of the multiplicative group of integers modulo pp
hhThe public key
xxThe private key

The public key is (p,g,h)(p, g, h) and the private key is (p,g,x)(p, g, x).

Key generation

The key generation is very similar to the one of the Diffie-Hellman key exchange.

  1. Choose a large prime pp.
  2. Choose a generator gg of the multiplicative group of integers modulo pp.
  3. Choose a random integer xx such that 1<x<p11 < x < p - 1.
  4. Compute the public key: h=gxmodph = g^x \mod p

Encryption (Textbook ElGamal)

To encrypt a message mm with the public key (p,g,h)(p, g, h), compute the ciphertext (c1,c2)(c_1, c_2) with:

  1. Choose a random integer yy such that 1<y<p11 < y < p - 1.
  2. Compute the first part of the ciphertext: c1=gymodpc_1 = g^y \mod p
  3. Compute the second part of the ciphertext: c2=mhymodpc_2 = m \cdot h^y \mod p

Decryption (Textbook ElGamal)

To decrypt a ciphertext (c1,c2)(c_1, c_2) with the private key (p,g,x)(p, g, x), compute mm with:

m=c2(c1x)1modpm = c_2 \cdot (c_1^x)^{-1} \mod p

m is the deciphered message.

Attacks