Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How find a variable value in MOD expression?

Tags:

math

modulo

shift

9 = 2^X mod 11

What is X and how do you find X?

Its related to finding the plain text in RSA algorithm and I'm writing a C program for it.

like image 687
user220446 Avatar asked Jul 27 '26 16:07

user220446


1 Answers

The answer is 6 + 10i for any integer i.

A simple way to get solutions for small moduli is to iterate over all values of x. You only need to check between 0 and 10 (= 11 - 1) to find the first solution, if any solution exists.

x = 0
while x < 50:
    if 9 == 2**x % 11:
         print x
    x += 1

Output:

6
16
26
36
46

Obviously this will take a long time if the modulus is large.

More information is on the Discrete Logarithm page. Note:

No efficient classical algorithm for computing general discrete logarithms logbg is known. The naive algorithm is to raise b to higher and higher powers k until the desired g is found; this is sometimes called trial multiplication. This algorithm requires running time linear in the size of the group G and thus exponential in the number of digits in the size of the group.

If it were easy to invert modular exponetiation, it wouldn't be a good cryptographic primitive.

like image 94
Mark Byers Avatar answered Jul 30 '26 09:07

Mark Byers



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!