Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 149
def Wiener (n, s): M = 10101 E = M.powermod(s,n)#&^(M, s) % n cf = continued_fraction(s/n)# convert(n / s, confrac) m = len(cf) for i in range(0, m ): t = cf.quotient(i)#numtheory:-nthnumer(cf, i) d = E.powermod(t,n)#&^(E, t) % n #print d if d == M: print("k:= {0}".format(cf.quotient( i))) print("The totient of the modulus is {0}".format((s*t)/(cf.quotient(i)))) print("The private key is {0}".format(t)) return t print("Private key not found")
n=90581 s=17993 Wiener(n,s)
k:= 5 The totient of the modulus is 17993 The private key is 5 5
R=3265396711756983478982942427377320885096893489866655598260006241001719943931507310110305762543773605123598690367438315377 e=1939655312447268406021170379072784619929989121975155903143975018481200182278586490890971801975947175016196157154785457257 Wiener(R,e)
Private key not found
d = inverse_mod(e,n)
d
72465