ElGamal encryption

{{Short description|Public-key cryptosystem}}

{{Redirect|ElGamal|signature algorithm|ElGamal signature scheme}}

In cryptography, the ElGamal encryption system is an asymmetric key encryption algorithm for public-key cryptography which is based on the Diffie–Hellman key exchange. It was described by Taher Elgamal in 1985.{{cite journal |author=Taher ElGamal |title=A Public-Key Cryptosystem and a Signature Scheme Based on Discrete Logarithms |journal=IEEE Transactions on Information Theory |volume=31 |issue=4 |year=1985 |pages=469–472 |doi=10.1109/TIT.1985.1057074 |url=https://caislab.kaist.ac.kr/lecture/2010/spring/cs548/basic/B02.pdf|citeseerx=10.1.1.476.4791 |s2cid=2973271 }} (conference version appeared in CRYPTO'84, pp. 10–18) ElGamal encryption is used in the free GNU Privacy Guard software, recent versions of PGP, and other cryptosystems. The Digital Signature Algorithm (DSA) is a variant of the ElGamal signature scheme, which should not be confused with ElGamal encryption.

ElGamal encryption can be defined over any cyclic group G, like multiplicative group of integers modulo n if and only if n is 1, 2, 4, pk or 2pk, where p is an odd prime and {{nowrap|k > 0}}. Its security depends upon the difficulty of the Decisional Diffie Hellman Problem in G.

The algorithm

The algorithm can be described as first performing a Diffie–Hellman key exchange to establish a shared secret s, then using this as a one-time pad for encrypting the message. ElGamal encryption is performed in three phases: the key generation, the encryption, and the decryption. The first is purely key exchange, whereas the latter two mix key exchange computations with message computations.

= Key generation =

The first party, Alice, generates a key pair as follows:

  • Generate an efficient description of a cyclic group G\, of order q\, with generator g. Let e represent the identity element of G.
  • : It is not necessary to come up with a group and generator for each new key. Indeed, one may expect a specific implementation of ElGamal to be hardcoded to use a specific group, or a group from a specific suite. The choice of group is mostly about how large keys you want to use.
  • Choose an integer x randomly from \{1, \ldots, q-1\}.
  • Compute h := g^x.
  • The public key consists of the values (G,q,g,h). Alice publishes this public key and retains x as her private key, which must be kept secret.

= Encryption =

A second party, Bob, encrypts a message M to Alice under her public key (G,q,g,h) as follows:

  • Map the message M to an element m of G using a reversible mapping function.
  • Choose an integer y randomly from \{1, \ldots, q-1\}.
  • Compute s := h^y. This is called the shared secret.
  • Compute c_1 := g^y.
  • Compute c_2 := m \cdot s.
  • Bob sends the ciphertext (c_1,c_2) to Alice.

Note that if one knows both the ciphertext (c_1,c_2) and the plaintext m, one can easily find the shared secret s, since c_2 \cdot m^{-1} = s. Therefore, a new y and hence a new s is generated for every message to improve security. For this reason, y is also called an ephemeral key.

= Decryption =

Alice decrypts a ciphertext (c_1, c_2) with her private key x as follows:

  • Compute s := c_1^x. Since c_1 = g^y, c_1^x = g^{xy} = h^y, and thus it is the same shared secret that was used by Bob in encryption.
  • Compute s^{-1}, the inverse of s in the group G. This can be computed in one of several ways. If G is a subgroup of a multiplicative group of integers modulo n, where n is prime, the modular multiplicative inverse can be computed using the extended Euclidean algorithm. An alternative is to compute s^{-1} as c_1^{q-x}. This is the inverse of s because of Lagrange's theorem, since s \cdot c_1^{q-x} = g^{xy} \cdot g^{(q-x)y} = (g^{q})^y = e^y = e.
  • Compute m := c_2 \cdot s^{-1}. This calculation produces the original message m, because c_2 = m \cdot s; hence c_2 \cdot s^{-1} = (m \cdot s) \cdot s^{-1} = m \cdot e = m.
  • Map m back to the plaintext message M.

= Practical use =

Like most public key systems, the ElGamal cryptosystem is usually used as part of a hybrid cryptosystem, where the message itself is encrypted using a symmetric cryptosystem, and ElGamal is then used to encrypt only the symmetric key. This is because asymmetric cryptosystems like ElGamal are usually slower than symmetric ones for the same level of security, so it is faster to encrypt the message, which can be arbitrarily large, with a symmetric cipher, and then use ElGamal only to encrypt the symmetric key, which usually is quite small compared to the size of the message.

Security

The security of the ElGamal scheme depends on the properties of the underlying group G as well as any padding scheme used on the messages. If the computational Diffie–Hellman assumption (CDH) holds in the underlying cyclic group G, then the encryption function is one-way.{{cite web

| url=https://crypto.cs.uiuc.edu/wiki/index.php/Elgamal_encryption_scheme

| title=Elgamal encryption scheme

| author= Mike Rosulek

| date=2008-12-13

| publisher=University of Illinois at Urbana-Champaign

| archive-url=https://web.archive.org/web/20160722005050/https://crypto.cs.uiuc.edu/wiki/index.php/Elgamal_encryption_scheme

| archive-date=2016-07-22

| url-status=dead}}

If the decisional Diffie–Hellman assumption (DDH) holds in G, then

ElGamal achieves semantic security.{{cite book

| first1=Yiannis

| last1=Tsiounis

| first2=Moti

| last2=Yung

| title=Public Key Cryptography

| chapter=On the security of ElGamal based encryption

| date=2006-05-24

| pages=117–134

| volume=1431

| doi=10.1007/BFb0054019

| isbn=978-3-540-69105-1

| series=Lecture Notes in Computer Science

}}

Semantic security is not implied by the computational Diffie–Hellman assumption alone. See Decisional Diffie–Hellman assumption for a discussion of groups where the assumption is believed to hold.

ElGamal encryption is unconditionally malleable, and therefore is not secure under chosen ciphertext attack. For example, given an encryption (c_1, c_2) of some (possibly unknown) message m, one can easily construct a valid encryption (c_1, 2 c_2) of the message 2m.

To achieve chosen-ciphertext security, the scheme must be further modified, or an appropriate padding scheme must be used. Depending on the modification, the DDH assumption may or may not be necessary.

Other schemes related to ElGamal which achieve security against chosen ciphertext attacks have also been proposed. The Cramer–Shoup cryptosystem is secure under chosen ciphertext attack assuming DDH holds for G. Its proof does not use the random oracle model. Another proposed scheme is DHIES,{{cite book

| first1=Michel

| last1=Abdalla

| first2=Mihir

| last2=Bellare

| first3=Phillip

| last3=Rogaway

| title=Topics in Cryptology — CT-RSA 2001

| chapter=The Oracle Diffie-Hellman Assumptions and an Analysis of DHIES

| date=2001-01-01

| series=Lecture Notes in Computer Science

| volume=2020

| pages=143–158

| doi=10.1007/3-540-45353-9_12

| isbn=978-3-540-41898-6

| chapter-url=https://link.springer.com/chapter/10.1007/3-540-45353-9_12}} whose proof requires an assumption that is stronger than the DDH assumption.

Efficiency

ElGamal encryption is probabilistic, meaning that a single plaintext can be encrypted to many possible ciphertexts, with the consequence that a general ElGamal encryption produces a 1:2 expansion in size from plaintext to ciphertext.

Encryption under ElGamal requires two exponentiations; however, these exponentiations are independent of the message and can be computed ahead of time if needed. Decryption requires one exponentiation and one computation of a group inverse, which can, however, be easily combined into just one exponentiation.

See also

Further reading

  • {{cite book |author1=A. J. Menezes |author2=P. C. van Oorschot |author3=S. A. Vanstone |publisher=CRC Press |chapter-url=https://cacr.uwaterloo.ca/hac/about/chap8.pdf |title=Handbook of Applied Cryptography |chapter=Chapter 8.4 ElGamal public-key encryption}}
  • {{cite book |author=Dan Boneh |title=Algorithmic Number Theory |chapter=The Decision Diffie-Hellman problem |series=Lecture Notes in Computer Science |year=1998 |volume=1423 |pages=48–63 |doi=10.1007/BFb0054851 |url=https://crypto.stanford.edu/~dabo/abstracts/DDH.html |isbn=978-3-540-64657-0 |citeseerx=10.1.1.461.9971 |author-link=Dan Boneh}}

References

{{reflist}}

{{Cryptography navbox | public-key}}

{{DEFAULTSORT:Elgamal Encryption}}

Category:Public-key encryption schemes