python在模数中生成数字

时间:2017-05-04 13:42:07

标签: python rsa timing-attack

我需要迭代生成数字x,这遵循这些条件

  • (x ^ z)mod n * x< Ñ
  • n已知,z在每个周期中都会发生变化

我需要它,因为我在RSA上实施定时攻击,并且需要生成这样的数字来测量时间而不模块化减少
感谢。

1 个答案:

答案 0 :(得分:0)

如果事先不知道z值列表,你可以试试coroutine:

def compute_current(x, n, z):
    # some computation here

def crunch(x, n):
    current = x
    z = yield current
    while True:
        current = compute_current(current, n, z)
        z = yield current

c = crunch(x=10)
next(c)

new_x = crunch.send(some_z)
newer_x = crunch.send(some_other_z)
...