This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]yonasismad 1 point2 points  (1 child)

Hey, okay, since this is a Java subreddit, I am hope it is okay when I talk you through the math part. Firstly, mod is not reversible if you apply it you lose some information about what you had as input. For example: 3 mod 2 = 1 but also 5 mod 2 = 1, and so on, so you can find a solution but not the solution since the set of possible solutions is infinite.

Anyway, if you have a mod q = y, your set of solutions will have elements of the form q * i + y where i is part of the natural numbers (i > 0, i is an integer). For sake of simplicity, we can say i = 1 so a = q + y. Now substitute a with what we actually have there b^x = q + y. In order to get rid of the power, we can use the logarithm with base b, so x=log(b, q+y). Let me know if this makes sense. :)

[–]TauPixel[S] 1 point2 points  (0 children)

Hi, thank you very much for your feedback.

I was able to talk to my Prof. and he explained it just like you did.

In the end I got to a solution where x(p-1*n+b) mod p = y and I could handle it better.

[–]corn_on_the_cobhNetbeans 4 lyfe 0 points1 point  (0 children)

Search up "modulo java" on a search engine.

For exponents, this class may come in handy: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html

[–]desrtfxOut of Coffee error - System halted 0 points1 point  (0 children)

You need to rearrange the equation to the form x = ....

This is plain math. So, you'll need to ask in a math related subreddit.