Microsoft Store
 

Elgamal encryption


 

The Elgamal algorithm is an asymmetric key encryption algorithm for public key cryptography which is based on Diffie-Hellman key agreement. It was described by Taher Elgamal in 1984. The Elgamal algorithm is used in the free GNU Privacy Guard software, recent versions of PGP, and other cryptosystems. The Digital Signature Algorithm is a signature scheme is a variant of the ElGamal signature scheme, which should not be confused with the Elgamal algorithm.

The algorithm

Elgamal consists of three components: the key generator, the encryption algorithm, and the decryption algorithm.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

The key generator works as follows:

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

  • Alice generates an efficient description of a cyclic group G of order q with generator g. See below for specific examples of how this can be done.
  • Alice chooses a random x from {0, ldots, q-1}.
  • Alice computes h = g^x.
  • Alice publishes h, along with the description of G, q, g, as her public key. Alice retains x as her secret key.
  • The encryption algorithm works as follows: to encrypt a message m to Alice under her public key (G,q,g,h),

    ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

  • Bob converts m into an element of G.
  • Bob chooses a random y from {0, ldots, q-1}, then calculates c_1=g^y and c_2=mcdot h^y.
  • Bob sends the ciphertext (c_1,c_2) to Alice.
  • The decryption algorithm works as follows: to decrypt a ciphertext (c_1,c_2) with her secret key x,

    ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

  • Alice computes c_2(c_1^x)^{-1} as the plaintext message.
  • The decryption algorithm produces the intended message, since

    ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

    c_2(c_1^x)^{-1} = rac{mcdot h^y}{g^{xy}} = rac{mcdot g^{xy}}{g^{xy}} = m

    ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

    If the space of possible messages is larger than the size of G, then the message can be split into several pieces and each piece can be encrypted independently. Typically, however, a short key to a symmetric-key cipher is first encrypted under Elgamal, and the (much longer) intended message is encrypted more efficiently using the symmetric-key cipher — this is termed hybrid encryption.

    ~ ~ ~ ~ ~ ~ ~ ~ ~ ~