The ElGamal Encryption
13 July 2021
The ElGamal Encryption is an asymmetric key encryption which means it uses public and private keys. The public key is ment to encrypt a message and the private key can then be used to decrypt it again. The choice of these keys is based on the pulic key system of the Diffie-Hellman key exchange.
The alorithm is prooven to be IND-CPA secure under the assumption that the Diffie-Hellman problem (the solving of the discrete logarithm) is nearly impossible to solve.
But let's not get into too much technical detail and have a look at the actual algorithm and a few examples.
The Algorithm
The initial set-up for the ElGamal encryption is similar to the Diffie-Hellman Key Exchange. Let's assume that Alice wants to send an encrypted message to Bob. First, they have to agree on some common parameters: a cyclic group of order with generator . Then each of them needs to choose a secret key. Alice picks her secret key , calculates and sends her public key to Bob. He chooses his private key simultaneously and calculates his public key .
Before Alice can send her message she needs to map it to an element (or several elements ). She then chooses a random number and calculates
and
The tuple then represents the encrypted message and Alice can send it to Bob.
Bob can now decipher the message as follows:
Example of a Simple Mapping Algorithm
Before presenting an example of the ElGamal Algorithm, it might be interesting to see how a text message could be converted to elements in .
To make it as easy as possible, we will use the cyclic group of order and consider only capital letters, space ' ', period '.' and comma ',' as possible signs in out message . Furthermore, we identify the signs as follows: , , , ..., ' ' , and .
If Alice now wanted to send the message "HELLO BOB.", she would use "" for the ElGamal Encryption.
Of course, not every cyclic group has such a convenient and obivious mapping algorithm. In addition, the group is far too small to guarantee any kind of security for the ElGamal algorithm. In reality the prime numbers (here ) are much bigger and therefore other and more complicated mapping algorithms are used.
ElGamal Encryption in
As an example we choose the finite group of order with the generator . is a generator of the group because
Now, that the basic framework is defined, Bob chooses his secret key , calculates
and sends to Alice. She has already mapped a message to and chooses a random number . Then, Alice encrypts her message as follows:
Alice sends the tuple to Bob and he deciphers it with the help of :
These examples are certainly insecure and not appropriate for modern cybersecurity. Nevertheless, the method is definitley used by big internet applications. Like the Diffie-Hellman Key Exchange, the ElGamal encryption can also be used in different mathematical environments or can even be used as a base for a digital signature algorithm.
A cyclic group is a group generated by some element with . has order if and whenever .
In a cyclic group of order the inverse of can be written as since with .
Note that is not the only possible generator. , , or could also be used.
The neutral element is here represented through .