Show how if Alice uses the same value of $k$ to sign two different messages $m_1$ and $m_2$, using the ElGamal signature scheme, Eve can recover the value of $a$ from the corresponding signatures $(m_1, r_1, s_1)$ and $(m_2, r_2, s_2)$. (Note: you are allowed to assume that if $\gcd(a, n) = d$ then there are $d$ solutions to the congruence $ax \equiv b \pmod n$.)
ElGamal Signature Scheme:
Key Gen:
Compute $y = g^x \;\bmod p$.
The public key is $(p, g, y)$. The secret key is $(p, g, x)$
Signature Gen:
Choose a random $k$ such that $0 < k < p − 1$ and $\gcd(k, p − 1) = 1$
Compute $r = g^k \;\bmod p$ and $s = k^{-1}(m – xr) \;\bmod{p-1}$
Thoughts: So far, I can tell that $r_1$ and $r_2$ are equal and $s_1$ and $s_2$ are closely related since the only variation is $m$.
We can relate the two equations for $s$, by solving them for $-xr$:
$$s_1k - m_1 \equiv s_2k - m_2 \pmod p$$
$$(s_1 - s_2)k \equiv m_1 - m_2 \pmod p$$
Let $a = s_1 - s_2$, then we know from the question that for $\gcd(a, n) = d$ there are $d$ solutions for $k$.
Now the forger can compute $g^k$ for each solution to k, until $r$ is found.
Then compute $xr \equiv m_1 - ks_1 \pmod{p-1}$
There are $d' = \gcd(r, p-1)$ solutions for $x$.
The forger can compute $g^x$ for all the $x$s found until she finds $y$.
Once she has $y$ she knows the proper $x$ which can be used to find $m_1$ and $m_2$.
How does this look?