Tell me more ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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

share|improve this question
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 Yuan Sep 28 '12 at 4:43

Questions on Mathematics Stack Exchange are expected to relate to math within the scope defined in the FAQ. 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 closed questions here.

1 Answer

You are trying to solve a discrete log. There are a number of algorithms to do this. Since you have a computer though and you know is is between 1 and 256, why not do brute force? It wouldn't take but a few seconds on a computer.

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.

share|improve this answer
sorry, after reading over the hw again, K is actually 256 bytes of randomness. – yao jiang Sep 27 '12 at 16:43
@yaojiang, that is tricky then. Can you post the values of the other variables. If this is a strong instance of elgamal with proper parameters (bit lengths, etc) then you shouldn't be able to solve for k. – mikeazo Sep 27 '12 at 16:47
edited with the values of the variables – yao jiang Sep 27 '12 at 18:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.