Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ashutosh1206
GitHub Repository: ashutosh1206/crypton
Path: blob/master/RSA-encryption/Attack-Coppersmith/exploit.py
1402 views
1
from sage.all import *
2
3
# f is the monic polynomial f(x) = (m + x)**e - c whose roots we have to find
4
def stereotyped(f, N):
5
P.<x> = PolynomialRing(Zmod(N))
6
beta = 1
7
dd = f.degree() # Degree of the polynomial
8
epsilon = beta/7
9
XX = ceil(N**((beta**2/dd) - epsilon))
10
rt = f.small_roots(XX, beta, epsilon)
11
return rt
12
13
def N-factorize(f, N):
14
P.<x> = PolynomialRing(Zmod(N))
15
beta = 0.5
16
dd = f.degree() # Degree of the polynomial
17
epsilon = beta/7
18
XX = ceil(N**((beta**2/dd) - epsilon))
19
rt = f.small_roots(XX, beta, epsilon)
20
return rt
21
22