ElGamal
links: AC2 TOC - RSA and ElGamal Encryption - Index
ElGamal Encryption Scheme

ElGamal Key Generation
The key generation of ElGamal takes a random secret key which is a random number in the range between and a given prime . The public key is then calculated by exponentiation of the generator as base with the private key as exponent:

ElGamal Encryption and Decryption
Encryption and Decryption with ElGamal can be done pretty sweet. For encryption we first calculate some random in the additive group . Then we calculate two return values and . is the generator potentiated with the random and is the public key of the receiving party potentiated with random multiplied with the message . Then and are returned.
Decryption is done by reverting the calculation using the private key of the receiving party. Therefore is potentiated with the negative value of the secret key. Then is multiplied with the received ciphertext . This leads to the resolution of all factors until only the plaintext is left.
Important: Each single operation is done inside the publicly known group , which means each operation is calculated like .
Resolution in detail:

Example

ElGamal Properties

Information about Gq subgroup
Information about why DDH doesn't hold in
GPT
The Decisional Diffie-Hellman (DDH) assumption is a computational problem in cryptography. Specifically, it's an assumption made about the difficulty of a specific computational task in a cyclic group. The problem is to distinguish between the distributions and for random , , and .
In the multiplicative group (where is prime), the DDH assumption does not hold. This is because if you have access to a group element, you can easily compute its square root (modulo ). This means you can distinguish between a random group element and a square. Thus, given and , it's possible to check whether the third element is the product of the first two (modulo ) or not.
On the other hand, if we consider a subgroup of , where for and prime (which makes a safe prime), and is the subgroup of quadratic residues modulo , the DDH assumption is believed to hold. This is because in this subgroup, it's computationally difficult to distinguish between a random element and a square, hence making it difficult to decide whether the third element is the product of the first two or not.
To summarize, the DDH problem is easier to solve in the full group (thus the DDH assumption does not hold), but is believed to be hard in the specific subgroup (thus the DDH assumption is considered to hold). This difference arises due to the mathematical properties of these groups and the specific structure of the DDH problem.
links: AC2 TOC - RSA and ElGamal Encryption - Index