Given a cyclic group G\mathbb{G}G of order qqq and its generator ggg, the encryption and decryption process for a message MMM is defined as follows.
Select a secret key xxx randomly from the range 1≤x<q−11 \leq x < q-11≤x<q−1.
Compute the public key yyy as follows:
Map the message MMM to an element m∈Gm \in \mathbb{G}m∈G.
Select a random value kkk from the range 1≤k<q−11 \leq k < q-11≤k<q−1.
Compute the shared secret sss:
Generate the ciphertext (c1,c2)(c_1, c_2)(c1,c2) as follows:
Recover the shared secret sss (This can only be done by the owner of xxx):
Retrieve the original message mmm:
Convert mmm back to the message MMM.
https://en.wikipedia.org/wiki/ElGamal_encryptionarrow-up-right
Written by Ryan Kim of Fractalyze
Last updated 2 months ago