Alice chooses El Gamal cryptosystem and prime number $47$. Then she choose primitive root $g=5$. Then Alice chooses private key and calculates public key $A=3$. Bob encrypts message $m$ and sends pair $(c_1, c_2) = (14, 16)$. Eve knows that message is from set $\{5, 6, 7\}$, and after analysis, Eve founds what was original message. Question is what did Eve do in order to find original message?
I would like if someone can check my solution confirm this is a correct way.
First, I have tried to find Alice's private key $a$ by solving using brute force:
$$ 5^a \equiv 3\ (mod\ 47) $$
and I have found that for $a=20$ above expression is satisfied.
Then I wrote next equation:
$$ {c_1}^{a} \equiv A^{k_m}\ (mod\ p) $$ $$ 14^{20} \equiv A^{k_m}\ (mod\ 47) $$ $$ 14^5 * 14^5 * 14^5 * 14^5 \equiv A^{k_m}\ (mod\ 47) $$ $$ 3^4 \equiv A^{k_m}\ (mod\ 47) $$
And from here I got $A^{k_m} = 34$. Next I have calculated:
$$(A^{k_m})^{-1} \equiv B\ (mod\ 47) $$ $$34^{-1} \equiv B\ (mod\ 47) $$
And I can write this as: $$ 34B \equiv 1\ (mod\ 47) $$
Now I can solve this for B using Euclid's Algorithm and find that $B=18$. Finally I wrote:
$$ c_2 * B = 16 * 18 = 288 \equiv 6\ (mod\ 47) $$
Meaning, original message was $m=6$.
My question here is, is this correct way to do this? I know I get 6 and in text of task, it says message is from set $\{5, 6, 7\}$, but I don't have any source to check my steps.