python生成模中的数

python生成模中的数,python,rsa,timing-attack,Python,Rsa,Timing Attack,我需要迭代生成数字x,它遵循以下条件 (x^z)模n*x

我需要迭代生成数字x,它遵循以下条件

  • (x^z)模n*x
  • n是已知的,z在每个循环中都会变化
我需要它,因为我正在对RSA实施定时攻击,需要生成这样的数字来测量时间,而不需要模块化缩减

谢谢。

如果事先不知道z值的列表,您可能会为此尝试协同程序:

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)
...

你的问题是什么?如何生成这样的数字我很困惑。您已经知道如何生成它。这个公式就在你的帖子里。我就是想不出,如何用这个公式来表示x