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 Zp1Z_{p-1} (between 0 and p2p-2).
  4. Compute β=αamodp\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: ZpZ_p^*.
  • Signature space: Z<em>p×Z</em>p1Z<em>p^* \times Z</em>{p-1}. This differs from the Elgamal cryptosystem's ciphertext space (Z<em>p×Z</em>pZ<em>p^* \times Z</em>p^*.

Signing Algorithm (Alice signs message x to Bob)

  1. Select a random number kk from Z<em>p1Z<em>{p-1}^*. This means kk has an inverse in Z</em>p1Z</em>{p-1}. (Note: p1p-1 is not prime).
    • To select such a kk, pick a random number from Zp1Z_{p-1} and compute gcd(k,p1)\gcd(k, p-1).
      • If gcd(k,p1)=1\gcd(k, p-1) = 1, then kZp1k \in Z_{p-1}^*.
      • If \gcd(k, p-1) > 1, discard kk and try again.
  2. Compute γ=αkmodp\gamma = \alpha^k \mod p.
  3. Compute δ=(xaγ)k1mod(p1)\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 k1k^{-1} (the inverse of the random number). The inverse exists because kk was chosen from Zp1Z_{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:
    βγγδαxmodp\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.
  • βγγδαxmodp\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δmodp\beta^{\gamma} \cdot \gamma^{\delta} = \alpha^{a\gamma} \cdot \alpha^{k\delta} = \alpha^{a\gamma + k\delta} \mod p
  • Since δ=(xaγ)k1mod(p1)\delta = (x - a\gamma)k^{-1} \mod (p-1), then kδ=xaγmod(p1)k\delta = x - a\gamma \mod (p-1), which means kδ+aγ=xmod(p1)k\delta + a\gamma = x \mod (p-1).
  • Therefore, aγ+kδ=x+t(p1)a\gamma + k\delta = x + t(p-1) for some integer tt.
  • Substituting back, αaγ+kδ=αx+t(p1)=αxαt(p1)=αx(αp1)tmodp\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 ZpZ_p^*, αp11modp\alpha^{p-1} \equiv 1 \mod p.
  • Thus, αx(αp1)tαx1tαxmodp\alpha^x \cdot (\alpha^{p-1})^t \equiv \alpha^x \cdot 1^t \equiv \alpha^x \mod p.
  • Therefore, βγγδαxmodp\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 βγγδαxmodp\beta^{\gamma} \cdot \gamma^{\delta} \equiv \alpha^x \mod p.
  • Oscar can choose γ\gamma randomly and try to construct a suitable δ\delta.
  • From βγγδαxmodp\beta^{\gamma} \cdot \gamma^{\delta} \equiv \alpha^x \mod p, we get γδαxβγmodp\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 ZpZ_p^*.
Picking Delta First
  • Oscar picks δ\delta and then tries to construct a suitable γ\gamma.
  • βγγδαxmodp\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.
  • xlogα(βγγδ)modpx \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.
    • iZp1i \in Z_{p-1}.
    • jZp1j \in Z_{p-1}^*. (i.e., gcd(j,p1)=1\gcd(j, p-1) = 1).
  2. Compute γ=αiβjmodp\gamma = \alpha^i \cdot \beta^j \mod p.
  3. Compute δ=γj1mod(p1)\delta = -\gamma j^{-1} \mod (p-1).
  4. Compute x=γij1mod(p1)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)γj1=βαiβj(αiγj1βγ)=βαiβjαx=αxmodp\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.
  • δ=(xaγ)k1mod(p1)\delta = (x - a\gamma)k^{-1} \mod (p-1) becomes kδ=xaγmod(p1)k\delta = x - a\gamma \mod (p-1).
  • aγ=xkδmod(p1)a\gamma = x - k\delta \mod (p-1) becomes a=(xδk)γ1mod(p1)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 γ=αkmodp\gamma = \alpha^k \mod p.
  3. Oscar observes both messages.
  4. Since signatures are valid, βγγδ<em>1αx</em>1modp\beta^{\gamma} \cdot \gamma^{\delta<em>1} \equiv \alpha^{x</em>1} \mod p and βγγδ<em>2αx</em>2modp\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>1x</em>2modp\gamma^{\delta<em>1 - \delta</em>2} \equiv \alpha^{x<em>1 - x</em>2} \mod p.
  6. Substituting γ=αkmodp\gamma = \alpha^k \mod p: αk(δ<em>1δ</em>2)αx<em>1x</em>2modp\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>1x</em>2mod(p1)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 (p1)(p-1), then k=(x<em>1x</em>2)(δ<em>1δ</em>2)1mod(p1)k = (x<em>1 - x</em>2)(\delta<em>1 - \delta</em>2)^{-1} \mod (p-1).
Unlucky Day Scenario
  1. If \gcd(\delta1 - \delta2, 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>1x</em>2)/d,p=(p1)/d\delta' = (\delta<em>1 - \delta</em>2) / d, x' = (x<em>1 - x</em>2) / d, p' = (p - 1) / d
  3. kδ=xmodpk*\delta' = x' mod p'
  4. Thus, δ\delta' has an inverse ϵ\epsilon modulo pp'.
  5. Multiplying by ϵ\epsilon gives k=xϵmodpk = x' \epsilon mod p'.
  6. Lifting to k=xϵ+ipk = x' \epsilon + i p' for some ii between 0 and d1d-1
  7. Find correct k by testing the values of k that satisfy equality. Test all ks with γαkmodp\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.