So I get the basics of diffie-hellman, discrete logarithms, modular arithmetic etc but I feel like I am missing something substantial or I would not be able to reverse it so easily, unless it is due to me using much smaller numbers. I used wikipeida's example when trying to understand it
So p=23, g=5, a=6, b=23, A=8, B=19, s=2 Eve can see A, B, p and g therefore
If $A\equiv g^a \pmod {p}$ then $a\equiv ind_5 (8) \pmod {23} =6+22k_a$
If $B\equiv g^b \pmod {p}$ then $b\equiv ind_5 (19) \pmod {23} =15+22k_b$
$s=A^b \pmod {p} =g^{ab} \pmod {p}$
I have found all values $5^{(6+22i)*(15+22j)} \pmod {23}=2$ so how is this secure?
Examples:
$(6+22(1))*(15+22(1)) = 90$, $5^{90} \pmod {23} = 2$
$(6+22(3))*(15+22(2)) = 90$, $5^{4248} \pmod {23} = 2$
$(6+22(3))*(15+22(3)) = 90$, $5^{5832} \pmod {23} = 2$
Is the magic of the discrete logarithm simply that it takes so many passes to find the information? Or was there a principle in choosing a, b, g and/or p that was ignored that made it solvable at all?
It's because in practice one would use a vastly larger value of $p$, hundreds or even thousands of digits long, and to naively invert $g^a$ you would have to check up to $p-1$ powers of $g$.