Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ashutosh1206
GitHub Repository: ashutosh1206/crypton
Path: blob/master/RSA-encryption/Attack-Franklin-Reiter/exploit.sage
1402 views
1
from sage.all import *
2
3
# All the variable names mean the same as mentioned in the explanation
4
# For eg, a,b are the values in the function f = ax + b
5
6
def gcd(a, b):
7
while b:
8
a, b = b, a % b
9
return a.monic()
10
11
def franklinreiter(C1, C2, e, N, a, b):
12
P.<X> = PolynomialRing(Zmod(N))
13
g1 = (a*X + b)^e - C1
14
g2 = X^e - C2
15
print "Result"
16
result = -gcd(g1, g2).coefficients()[0]
17
return hex(int(result))[2:].replace("L","").decode("hex")
18
19