# ElGamal signature scheme

The ElGamal signature scheme is a digital signature scheme which is based on the difficulty of computing discrete logarithms. It was described by Taher ElGamal in 1984.[1]

The ElGamal signature algorithm is rarely used in practice. A variant developed at NSA and known as the Digital Signature Algorithm is much more widely used. There are several other variants.[2] The ElGamal signature scheme must not be confused with ElGamal encryption which was also invented by Taher ElGamal.

The ElGamal signature scheme allows a third-party to confirm the authenticity of a message.

## System parametersEdit

These system parameters may be shared between users.

## Key generationEdit

• Randomly choose a secret key x with 1 < x < p − 2.
• Compute y = g x mod p.
• The public key is y.
• The secret key is x.

These steps are performed once by the signer.

## Signature generationEdit

To sign a message m the signer performs the following steps.

• Choose a random k such that 1 < k < p − 1 and gcd(kp − 1) = 1.
• Compute ${\displaystyle r\,\equiv \,g^{k}{\pmod {p}}}$ .
• Compute ${\displaystyle s\,\equiv \,(H(m)-xr)k^{-1}{\pmod {p-1}}}$ .
• If ${\displaystyle s=0}$  start over again.

Then the pair (r,s) is the digital signature of m. The signer repeats these steps for every signature.

## VerificationEdit

A signature (r,s) of a message m is verified as follows.

• ${\displaystyle 0  and ${\displaystyle 0 .
• ${\displaystyle g^{H(m)}\equiv y^{r}r^{s}{\pmod {p}}.}$

The verifier accepts a signature if all conditions are satisfied and rejects it otherwise.

## CorrectnessEdit

The algorithm is correct in the sense that a signature generated with the signing algorithm will always be accepted by the verifier.

The signature generation implies

${\displaystyle H(m)\,\equiv \,xr+sk{\pmod {p-1}}.}$

Hence Fermat's little theorem implies

{\displaystyle {\begin{aligned}g^{H(m)}&\equiv g^{xr}g^{ks}\\&\equiv (g^{x})^{r}(g^{k})^{s}\\&\equiv (y)^{r}(r)^{s}{\pmod {p}}.\\\end{aligned}}}

## SecurityEdit

A third party can forge signatures either by finding the signer's secret key x or by finding collisions in the hash function ${\displaystyle H(m)\equiv H(M){\pmod {p-1}}}$ . Both problems are believed to be difficult. However, as of 2011 no tight reduction to a computational hardness assumption is known.

The signer must be careful to choose a different k uniformly at random for each signature and to be certain that k, or even partial information about k, is not leaked. Otherwise, an attacker may be able to deduce the secret key x with reduced difficulty, perhaps enough to allow a practical attack. In particular, if two messages are sent using the same value of k and the same key, then an attacker can compute x directly.[1]

### Existential forgeryEdit

The original paper[1] did not include a hash function as a system parameter. The message m was used directly in the algorithm instead of H(m). This enables an attack called existential forgery, as described in section IV of the paper. Pointcheval and Stern generalized that case and described two levels of forgeries:[3]

1. The one-parameter forgery. Let ${\displaystyle 1  be a random element. If ${\displaystyle r=g^{e}y{\pmod {p}}}$  and ${\displaystyle s=-r{\pmod {p-1}}}$ , the tuple ${\displaystyle (r,s)}$  is a valid signature for the message ${\displaystyle m=es{\pmod {p-1}}}$ .
2. The two-parameters forgery. Let ${\displaystyle 1  and be random elements and ${\displaystyle \gcd(v,p-1)=1}$ . If ${\displaystyle r=g^{e}y^{v}{\pmod {p}}}$  and ${\displaystyle s=-rv^{-1}{\pmod {p-1}}}$ , the tuple ${\displaystyle (r,s)}$  is a valid signature for the message ${\displaystyle m=es{\pmod {p-1}}}$ .

Improved version (with a hash) is known as Pointcheval–Stern signature algorithm