Elgamal Signature Scheme

Elgamal Signature Scheme

  • Developed by Elgamal around 1985, alongside the Elgamal cryptosystem.
  • The United States National Standard for Digital Signature Scheme (approved by NIST) is based upon the Elgamal Signature Scheme.
  • Requires closer attention due to the density of mathematics.

Differences from RSA Signature Scheme

  • RSA signature scheme utilizes the RSA cryptosystem directly.
  • Elgamal signature scheme isn't a direct repurposing of the Elgamal cryptosystem because the Elgamal cryptosystem is not endomorphic which is a requirement to create a signature scheme

Two Conditions for Public Key Cryptosystem to be a Digital Signature Scheme:

  1. It has to be an endomorphic cryptosystem.
  2. Decrypting and then encrypting should return the original message.

Randomized Signature Scheme

  • Elgamal is a randomized signature scheme.
  • Uses a random number as part of the signing process.
  • Multiple possible valid signatures exist for the same message.
  • The verification algorithm must accept any valid signature.
  • Verification algorithm must accept any valid signature because there are many valid signatures.

Setup

  1. Select a large prime number pp (e.g., 2000 bits or 600 digits).
  2. Select α\alpha, a primitive element in ZpZ_p. (Zp is a cyclic group, meaning all elements can be generated by α\alpha).
  3. Select an exponent aa from Zp−1Z_{p-1} (between 0 and p−2p-2).
  4. Compute β=αamod  p\beta = \alpha^a \mod p.

Key Generation

  • The key consists of four parameters: pp, α\alpha, aa, and β\beta. This process is identical to Elgamal cryptosystem key generation.
  • pp, α\alpha, and β\beta are public.
  • aa is the secret key.

Spaces

  • Message (plaintext) space: Zp∗Z_p^*.
  • Signature space: Z<em>p∗×Z</em>p−1Z<em>p^* \times Z</em>{p-1}. This differs from the Elgamal cryptosystem's ciphertext space (Z<em>p∗×Z</em>p∗Z<em>p^* \times Z</em>p^*.

Signing Algorithm (Alice signs message x to Bob)

  1. Select a random number kk from Z<em>p−1∗Z<em>{p-1}^*. This means kk has an inverse in Z</em>p−1Z</em>{p-1}. (Note: p−1p-1 is not prime).
    • To select such a kk, pick a random number from Zp−1Z_{p-1} and compute gcd⁡(k,p−1)\gcd(k, p-1).
      • If gcd⁡(k,p−1)=1\gcd(k, p-1) = 1, then k∈Zp−1∗k \in Z_{p-1}^*.
      • If gcd⁡(k,p−1)>1\gcd(k, p-1) > 1, discard kk and try again.
  2. Compute γ=αkmod  p\gamma = \alpha^k \mod p.
  3. Compute δ=(x−aγ)k−1mod  (p−1)\delta = (x - a\gamma)k^{-1} \mod (p-1).
  • The signature is (γ,δ)\left(\gamma, \delta\right).
  • Alice sends (x,γ,δ)(x, \gamma, \delta) to Bob.
Efficiency
  • Gamma can be computed efficiently using modular exponentiation (square and multiply algorithm).
  • Delta involves: xx (the message), aa (Alice's private key), γ\gamma (computed in step 3), and k−1k^{-1} (the inverse of the random number). The inverse exists because kk was chosen from Zp−1∗Z_{p-1}^*.
  • The first computation is done modulo p, the second one modulo p-1.

Verification Algorithm

  1. Bob receives message xx and signature (γ,δ)(\gamma, \delta) from Alice.
  2. Bob checks if the following congruence holds:
    βγ⋅γδ≡αxmod  p\beta^{\gamma} \cdot \gamma^{\delta} \equiv \alpha^x \mod p
  3. Bob knows β,γ,δ,α,x,p\beta, \gamma, \delta, \alpha, x , p and can efficiently compute both sides of congruence and verify if it holds true or not.

Correctness of the Algorithm

  • If the signature is constructed properly by Alice, the verification algorithm should return true.
  • βγ⋅γδ≡αxmod  p\beta^{\gamma} \cdot \gamma^{\delta} \equiv \alpha^x \mod p
  • β=αa\beta = \alpha^a, so βγ=(αa)γ=αaγ\beta^{\gamma} = (\alpha^a)^{\gamma} = \alpha^{a\gamma}
  • γ=αk\gamma = \alpha^k, so γδ=(αk)δ=αkδ\gamma^{\delta} = (\alpha^k)^{\delta} = \alpha^{k\delta}
  • Thus, βγ⋅γδ=αaγ⋅αkδ=αaγ+kδmod  p\beta^{\gamma} \cdot \gamma^{\delta} = \alpha^{a\gamma} \cdot \alpha^{k\delta} = \alpha^{a\gamma + k\delta} \mod p
  • Since δ=(x−aγ)k−1mod  (p−1)\delta = (x - a\gamma)k^{-1} \mod (p-1), then kδ=x−aγmod  (p−1)k\delta = x - a\gamma \mod (p-1), which means kδ+aγ=xmod  (p−1)k\delta + a\gamma = x \mod (p-1).
  • Therefore, aγ+kδ=x+t(p−1)a\gamma + k\delta = x + t(p-1) for some integer tt.
  • Substituting back, αaγ+kδ=αx+t(p−1)=αx⋅αt(p−1)=αx⋅(αp−1)tmod  p\alpha^{a\gamma + k\delta} = \alpha^{x + t(p-1)} = \alpha^x \cdot \alpha^{t(p-1)} = \alpha^x \cdot (\alpha^{p-1})^t \mod p.
  • Because α\alpha is a primitive element in Zp∗Z_p^*, αp−1≡1mod  p\alpha^{p-1} \equiv 1 \mod p.
  • Thus, αx⋅(αp−1)t≡αx⋅1t≡αxmod  p\alpha^x \cdot (\alpha^{p-1})^t \equiv \alpha^x \cdot 1^t \equiv \alpha^x \mod p.
  • Therefore, βγ⋅γδ≡αxmod  p\beta^{\gamma} \cdot \gamma^{\delta} \equiv \alpha^x \mod p if the signature was constructed correctly.

Exponents always obey modulo p-1 arithmetic. Whenever you have an equation in modulo p, the exponents obey modulo p-1 arithmetic.

Security of Elgamal Signature Scheme

  • Security means that an opponent (Oscar) cannot forge Alice's signature.
  • Kirchhoff's principle: Oscar knows the scheme, but not Alice's private key (aa).
Forging a Message
  1. Oscar picks a message xx.
  2. Oscar needs to construct a signature (γ,δ)(\gamma, \delta) such that βγ⋅γδ≡αxmod  p\beta^{\gamma} \cdot \gamma^{\delta} \equiv \alpha^x \mod p.
  • Oscar can choose γ\gamma randomly and try to construct a suitable δ\delta.
  • From βγ⋅γδ≡αxmod  p\beta^{\gamma} \cdot \gamma^{\delta} \equiv \alpha^x \mod p, we get γδ≡αx⋅β−γmod  p\gamma^{\delta} \equiv \alpha^x \cdot \beta^{-\gamma} \mod p.
  • Thus, δ=log⁡γ(αx⋅β−γ)\delta = \log_{\gamma}(\alpha^x \cdot \beta^{-\gamma}), which is a discrete log problem.
  • Solving the discrete log problem is computationally difficult in Zp∗Z_p^*.
Picking Delta First
  • Oscar picks δ\delta and then tries to construct a suitable γ\gamma.
  • βγ⋅γδ≡αxmod  p\beta^{\gamma} \cdot \gamma^{\delta} \equiv \alpha^x \mod p. Here gammagamma appears in the exponent and base, and finding γ\gamma is a difficult problem.
Forging a Random Message
  • Oscar picks both γ\gamma and δ\delta randomly and then tries to build a message x for which (γ,γ,δ\gamma, \gamma, \delta) will be deemed as a valid signature.
  • x≡log⁡α(βγ⋅γδ)mod  px \equiv \log_{\alpha}(\beta^{\gamma} \cdot \gamma^{\delta}) \mod p. This is again a discrete log problem.
Simultaneous Construction of x, gamma, and delta
  1. Oscar selects two integers ii and jj.
    • i∈Zp−1i \in Z_{p-1}.
    • j∈Zp−1∗j \in Z_{p-1}^*. (i.e., gcd⁡(j,p−1)=1\gcd(j, p-1) = 1).
  2. Compute γ=αi⋅βjmod  p\gamma = \alpha^i \cdot \beta^j \mod p.
  3. Compute δ=−γj−1mod  (p−1)\delta = -\gamma j^{-1} \mod (p-1).
  4. Compute x=−γij−1mod  (p−1)x = -\gamma i j^{-1} \mod (p-1).
  • If Oscar builds x,γx, \gamma, and δ\delta this way, Bob will consider this a valid signature.
  • The verification involves:
    βγγδ=βαiβj(αiβj)−γj−1=βαiβj(α−iγj−1β−γ)=βαiβjαx=αxmod  p\beta^\gamma \gamma^\delta = \beta^{\alpha^i \beta^j} (\alpha^i \beta^j)^{-\gamma j^{-1}} = \beta^{\alpha^i \beta^j} (\alpha^{-i \gamma j^{-1}} \beta^{-\gamma}) = \beta^{\alpha^i \beta^j} \alpha^x = \alpha^x \mod p

Revealing the Random Number

  • If Alice accidentally reveals the random number kk, it is dangerous.
  • The opponent can figure out Alice's private key aa.
  • δ=(x−aγ)k−1mod  (p−1)\delta = (x - a\gamma)k^{-1} \mod (p-1) becomes kδ=x−aγmod  (p−1)k\delta = x - a\gamma \mod (p-1).
  • aγ=x−kδmod  (p−1)a\gamma = x - k\delta \mod (p-1) becomes a=(x−δk)γ−1mod  (p−1)a = (x - \delta k)\gamma^{-1} \mod (p-1).
  • Oscar knows x,γ,δ,kx, \gamma, \delta, k and can compute aa.

Reusing the Random Number

  1. Alice uses the same random number kk to sign two different messages, x<em>1x<em>1 and x</em>2x</em>2.
  2. (γ,δ<em>1)(\gamma, \delta<em>1) is the signature for x</em>1x</em>1, and (γ,δ<em>2)(\gamma, \delta<em>2) is the signature for x</em>2x</em>2, where γ=αkmod  p\gamma = \alpha^k \mod p.
  3. Oscar observes both messages.
  4. Since signatures are valid, βγ⋅γδ<em>1≡αx</em>1mod  p\beta^{\gamma} \cdot \gamma^{\delta<em>1} \equiv \alpha^{x</em>1} \mod p and βγ⋅γδ<em>2≡αx</em>2mod  p\beta^{\gamma} \cdot \gamma^{\delta<em>2} \equiv \alpha^{x</em>2} \mod p.
  5. Dividing the two equations: γδ<em>1−δ</em>2≡αx<em>1−x</em>2mod  p\gamma^{\delta<em>1 - \delta</em>2} \equiv \alpha^{x<em>1 - x</em>2} \mod p.
  6. Substituting γ=αkmod  p\gamma = \alpha^k \mod p: αk(δ<em>1−δ</em>2)≡αx<em>1−x</em>2mod  p\alpha^{k(\delta<em>1 - \delta</em>2)} \equiv \alpha^{x<em>1 - x</em>2} \mod p.
  7. Therefore, k(δ<em>1−δ</em>2)≡x<em>1−x</em>2mod  (p−1)k(\delta<em>1 - \delta</em>2) \equiv x<em>1 - x</em>2 \mod (p-1).
Lucky Day Scenario
  • If (δ<em>1−δ</em>2)(\delta<em>1 - \delta</em>2) has an inverse modulo (p−1)(p-1), then k=(x<em>1−x</em>2)(δ<em>1−δ</em>2)−1mod  (p−1)k = (x<em>1 - x</em>2)(\delta<em>1 - \delta</em>2)^{-1} \mod (p-1).
Unlucky Day Scenario
  1. If gcd⁡(δ<em>1−δ</em>2,p−1)=d>1\gcd(\delta<em>1 - \delta</em>2, p-1) = d > 1, then there's a new equation by dividing with gcd as follows
  2. δ′=(δ<em>1−δ</em>2)/d,x′=(x<em>1−x</em>2)/d,p′=(p−1)/d\delta' = (\delta<em>1 - \delta</em>2) / d, x' = (x<em>1 - x</em>2) / d, p' = (p - 1) / d
  3. k∗δ′=x′modp′k*\delta' = x' mod p'
  4. Thus, δ′\delta' has an inverse ϵ\epsilon modulo p′p'.
  5. Multiplying by ϵ\epsilon gives k=x′ϵmodp′k = x' \epsilon mod p'.
  6. Lifting to k=x′ϵ+ip′k = x' \epsilon + i p' for some ii between 0 and d−1d-1
  7. Find correct k by testing the values of k that satisfy equality. Test all ks with γ≡αkmod  p\gamma \equiv \alpha^k \mod p
  • Final Concluding statement: It is very very important that Allies does not use the same random number again and again. Well, not only again and again, not even for two different messages.