ElGamal Encryption

ElGamal is an asymmetric key encryption algorithm based on the Diffie-Hellman key exchange and the discrete logarithm problem.

Key Generation

Generate a new ElGamal key pair for encryption and decryption

Encrypt File

Upload a file and encrypt it with recipient's public key

Decrypt File

Upload an encrypted file and decrypt it with your private key

About ElGamal Encryption

ElGamal encryption is an asymmetric key encryption algorithm for public-key cryptography which is based on the Diffie-Hellman key exchange. It was described by Taher Elgamal in 1985.

  • ElGamal encryption consists of three components: the key generator, the encryption algorithm, and the decryption algorithm.
  • The security of the system relies on the difficulty of computing discrete logarithms in a cyclic group.
  • ElGamal can be used for both encryption and digital signatures, though its signature scheme is less commonly used today.
  • The algorithm is in the public domain and can be freely used.
How ElGamal Works:
  1. Key Generation:
    • Choose a large prime number p and a generator g of the multiplicative group of integers modulo p.
    • Select a random integer x (the private key) between 1 and p-2.
    • Compute h = g^x mod p (the public key).
    • The public key is (p, g, h), and the private key is x.
  2. Encryption:
    • To encrypt a message m, choose a random integer y between 1 and p-2.
    • Compute c₁ = g^y mod p.
    • Compute s = h^y mod p.
    • Compute c₂ = m × s mod p.
    • The ciphertext is (c₁, c₂).
  3. Decryption:
    • Compute s = c₁^x mod p.
    • Compute m = c₂ × s^(-1) mod p, where s^(-1) is the modular multiplicative inverse of s modulo p.
Characteristics of ElGamal:
  • Probabilistic Encryption: ElGamal is a probabilistic encryption scheme, meaning that encrypting the same message multiple times will yield different ciphertexts.
  • Ciphertext Expansion: The ciphertext is twice the size of the plaintext, which can be a disadvantage in some applications.
  • Computational Overhead: ElGamal is computationally more intensive than some other asymmetric algorithms like RSA.
  • Security: The security is based on the discrete logarithm problem, which is believed to be computationally hard.
Comparison with RSA:
Feature ElGamal RSA
Security Basis Discrete Logarithm Problem Integer Factorization Problem
Ciphertext Size Twice the plaintext size Same as key size
Encryption Speed Slower Faster
Decryption Speed Slower Faster
Probabilistic Yes (more secure against certain attacks) No (unless using padding schemes)