Elgamal

The Elgamal cryptosystem is a public key encryption scheme based on the difficulty of the discrete logarithm problem.

Setup

Choose a prime and a primitive root modulo .

Bob chooses a secret key and publishes

So the public key is and the private key is .

Encryption

To send a message modulo , Alice chooses a random integer and computes

These powers modulo are computed efficiently using Binary Exponentiation.

The ciphertext is the pair .

Decryption

Bob computes

and then recovers the plaintext by

Security Idea

An attacker sees and , but recovering or from those values requires solving a discrete logarithm problem.