First you factorise 928108726777524737. It has 2 prime factors, call them P and Q.
Then you need to find a value d
such that d * 65539 mod (P-1)(Q-1) == 1
(use the Extended Euclidian Algorithm for this).
Once you have done that then given c = pow (b, 65539, 928108726777524737)
you can calculate back to b
with pow(c, d, 928108726777524737)
To help you a bit more P=948712711
, Q=978282167
giving d=872653594828486879
>>> c = pow(99, 65539, 928108726777524737)
>>> pow(c, 872653594828486879, 928108726777524737)
99
Of course in real life you would start with the prime factors and make them a lot larger than this in which case it would be impractical to reverse the process without already knowing the factors. For small values such as this is it is easy to factorise and calculate the inverse.
Calculation of d
:
def egcd(a, b):
x,y, u,v = 0,1, 1,0
while a != 0:
q, r = b//a, b%a
m, n = x-u*q, y-v*q
b,a, x,y, u,v = a,r, u,v, m,n
gcd = b
return gcd, x, y
First find the prime factors:
>>> P, Q = 948712711, 978282167
>>> P*Q
928108726777524737
>>> egcd(65539, (P-1)*(Q-1))
(1, -55455130022042981, 3916)
We want the middle value x
:
>>> gcd, x, y = egcd(65539, (P-1)*(Q-1))
But we have to make it positive which we can do by adding on the (P-1)*(Q-1)
value:
>>> x + (P-1)*(Q-1)
872653594828486879