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:
- It has to be an endomorphic cryptosystem.
- 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
- Select a large prime number p (e.g., 2000 bits or 600 digits).
- Select α, a primitive element in Zp. (Zp is a cyclic group, meaning all elements can be generated by α).
- Select an exponent a from Zp−1 (between 0 and p−2).
- Compute β=αamodp.
Key Generation
- The key consists of four parameters: p, α, a, and β. This process is identical to Elgamal cryptosystem key generation.
- p, α, and β are public.
- a is the secret key.
Spaces
- Message (plaintext) space: Zp∗.
- Signature space: Z<em>p∗×Z</em>p−1. This differs from the Elgamal cryptosystem's ciphertext space (Z<em>p∗×Z</em>p∗.
Signing Algorithm (Alice signs message x to Bob)
- Select a random number k from Z<em>p−1∗. This means k has an inverse in Z</em>p−1. (Note: p−1 is not prime).
- To select such a k, pick a random number from Zp−1 and compute gcd(k,p−1).
- If gcd(k,p−1)=1, then k∈Zp−1∗.
- If gcd(k,p−1)>1, discard k and try again.
- Compute γ=αkmodp.
- Compute δ=(x−aγ)k−1mod(p−1).
- The signature is (γ,δ).
- Alice sends (x,γ,δ) to Bob.
Efficiency
- Gamma can be computed efficiently using modular exponentiation (square and multiply algorithm).
- Delta involves: x (the message), a (Alice's private key), γ (computed in step 3), and k−1 (the inverse of the random number). The inverse exists because k was chosen from Zp−1∗.
- The first computation is done modulo p, the second one modulo p-1.
Verification Algorithm
- Bob receives message x and signature (γ,δ) from Alice.
- Bob checks if the following congruence holds:
βγ⋅γδ≡αxmodp - Bob knows β,γ,δ,α,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
- β=αa, so βγ=(αa)γ=αaγ
- γ=αk, so γδ=(αk)δ=αkδ
- Thus, βγ⋅γδ=αaγ⋅αkδ=αaγ+kδmodp
- Since δ=(x−aγ)k−1mod(p−1), then kδ=x−aγmod(p−1), which means kδ+aγ=xmod(p−1).
- Therefore, aγ+kδ=x+t(p−1) for some integer t.
- Substituting back, αaγ+kδ=αx+t(p−1)=αx⋅αt(p−1)=αx⋅(αp−1)tmodp.
- Because α is a primitive element in Zp∗, αp−1≡1modp.
- Thus, αx⋅(αp−1)t≡αx⋅1t≡αxmodp.
- Therefore, βγ⋅γδ≡αxmodp 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 (a).
Forging a Message
- Oscar picks a message x.
- Oscar needs to construct a signature (γ,δ) such that βγ⋅γδ≡αxmodp.
- Oscar can choose γ randomly and try to construct a suitable δ.
- From βγ⋅γδ≡αxmodp, we get γδ≡αx⋅β−γmodp.
- Thus, δ=logγ(αx⋅β−γ), which is a discrete log problem.
- Solving the discrete log problem is computationally difficult in Zp∗.
Picking Delta First
- Oscar picks δ and then tries to construct a suitable γ.
- βγ⋅γδ≡αxmodp. Here gamma appears in the exponent and base, and finding γ is a difficult problem.
Forging a Random Message
- Oscar picks both γ and δ randomly and then tries to build a message x for which (γ,γ,δ) will be deemed as a valid signature.
- x≡logα(βγ⋅γδ)modp. This is again a discrete log problem.
Simultaneous Construction of x, gamma, and delta
- Oscar selects two integers i and j.
- i∈Zp−1.
- j∈Zp−1∗. (i.e., gcd(j,p−1)=1).
- Compute γ=αi⋅βjmodp.
- Compute δ=−γj−1mod(p−1).
- Compute x=−γij−1mod(p−1).
- If Oscar builds x,γ, and δ 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=αxmodp
Revealing the Random Number
- If Alice accidentally reveals the random number k, it is dangerous.
- The opponent can figure out Alice's private key a.
- δ=(x−aγ)k−1mod(p−1) becomes kδ=x−aγmod(p−1).
- aγ=x−kδmod(p−1) becomes a=(x−δk)γ−1mod(p−1).
- Oscar knows x,γ,δ,k and can compute a.
Reusing the Random Number
- Alice uses the same random number k to sign two different messages, x<em>1 and x</em>2.
- (γ,δ<em>1) is the signature for x</em>1, and (γ,δ<em>2) is the signature for x</em>2, where γ=αkmodp.
- Oscar observes both messages.
- Since signatures are valid, βγ⋅γδ<em>1≡αx</em>1modp and βγ⋅γδ<em>2≡αx</em>2modp.
- Dividing the two equations: γδ<em>1−δ</em>2≡αx<em>1−x</em>2modp.
- Substituting γ=αkmodp: αk(δ<em>1−δ</em>2)≡αx<em>1−x</em>2modp.
- Therefore, k(δ<em>1−δ</em>2)≡x<em>1−x</em>2mod(p−1).
Lucky Day Scenario
- If (δ<em>1−δ</em>2) has an inverse modulo (p−1), then k=(x<em>1−x</em>2)(δ<em>1−δ</em>2)−1mod(p−1).
Unlucky Day Scenario
- If gcd(δ<em>1−δ</em>2,p−1)=d>1, then there's a new equation by dividing with gcd as follows
- δ′=(δ<em>1−δ</em>2)/d,x′=(x<em>1−x</em>2)/d,p′=(p−1)/d
- k∗δ′=x′modp′
- Thus, δ′ has an inverse ϵ modulo p′.
- Multiplying by ϵ gives k=x′ϵmodp′.
- Lifting to k=x′ϵ+ip′ for some i between 0 and d−1
- Find correct k by testing the values of k that satisfy equality. Test all ks with γ≡αkmodp
- 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.