Wiener Attack
前言
本文是学习自下述网站
https://zhuanlan.zhihu.com/p/400818185
Note


脚本
# sage
def wiener_attack(n, e):n = Integer(n)e = Integer(e)cf = (e / n).continued_fraction().convergents()for f in cf:k = f.numer()d = f.denom()if k == 0:continuephin = ((e * d) - 1) / kb = -(n - phin + 1)dis = b ^ 2 - 4 * nif dis.sign() == 1:dis_sqrt = sqrt(dis)p = (-b + dis_sqrt) / 2q = (-b - dis_sqrt) / 2if p.is_integer() and q.is_integer() and (p * q) % n == 0:p = p % nq = q % nif p > q:return (p, q)else:return (q, p)
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
