Home > OS >  Inverse of pow(a,b,c) decrypt
Inverse of pow(a,b,c) decrypt

Time:09-04

I am working on a python decryption code using an encryption code that is already available.

In the encryption code, I have X = pow(a,b,c) I know X, a, c. How can I know value b?

CodePudding user response:

Assuming that

  • a is the base,
  • b is the power, and
  • c is the mod c-part in a^b mod c,

then computing b given a, c and a^b mod c would be the discrete logarithm problem, which is practically intractable for the cases you'd be usually interested in when dealing with cryptographic algorithms.

CodePudding user response:

You can't, that's the point. pow(a,b,c) is a ** b modulo c, where modulo means the remainder in an integer division by c. For example, pow(4, 3, 5) is 4 ** 3 modulo 5, which is 4 (4 ** 3 is 64, modulo 5 is 4 because that's the remainder of 60:5).

But you also get 4 as a result of, for example, pow(4, 1, 5) (because 4 ** 1 = 4, giving a remainder of 4).

So the bottom line is: You can't unambiguously derive b from having X, a and c in your equation because there are multiple bs that will fulfil the equation. That's one of the reasons why asymmetric encryption likes to use the modulo function.

  • Related