# doing an attack on elgamal using pycrypto, how do i solve for this random K? [closed]

I am working on a cryptography homework, doing an elgamal attack. I am using pycrypto's package.

$(a, b) = encrypt(plaintext, K)$

where

$a = g^K \bmod p$

$b = (M * (y^k \bmod p)) \bmod p$

note* $y = g^x$ where $x$ is $0$.

how do i solve for $K$ in $a$? i would assume that to find $K$ in $a$, i would first undo the $\bmod p$ then solve that for $K$?

basically all variables are known except $K$,

correction, $K$ is actually a string of randomly chosen bytes, pycrypto.Random.get_random_bytes(256)

update:

(iCrypto.PublicKey.ElGamal
ElGamalobj
(iCrypto.PublicKey.ElGamal
ElGamalobj
p1
(dp2
S'y'
L3851108076650641288865103389678956230722604113016323772542883708566042695644008397665742854007727536601555544224254199922001425133482034782803499737357184245616748558709909700229181276764625497768362623566917108742272367808698987110754258303723299827479960491382285630238295061089279364243463440349018971343L
sS'p'
L120053190728662558102422374586700575861948298252350519085804716660050499427167747567030668171459827826412019436749763634225321054729778015928332247569488011408830325041398940604454841455954677214120721456908809521766401310423837479141595303402653304941224929139831429625275738949439270847278126168426051651519L
sS'g'
L28991607564753802504963461845896331885785976942821514499992205373352914326576115941685850070173798014037739188429161396978995546358116441948086532566777217447608039716620041152660962365559509983758664678029052189336271879635235368066382762520741617211910831541515492066943985149654383092191556264270212205239L
sS'x'
L0L
sb.


this is what the professor gave us, (y,p,g) are all huge primes(i think) and x is 0

-
if $x=0$ why is $y$ not $1$? –  mikeazo Sep 27 '12 at 18:55
im starting to get more confused... y = g^x where x is some super secret key, i think the 0 there is just the prof messing with us then. –  yao jiang Sep 27 '12 at 19:24

## closed as off topic by Qiaochu YuanSep 28 '12 at 4:43

Questions on Mathematics Stack Exchange are expected to relate to math within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

If for the purposes of your homework, brute-force is not allowed, Baby-step giant-step wouldn't be too bad to do by hand since $K$ is small.