pythonrsatiming-attack

python generating numbers in modulus


i need to iteratively generate number x, which follow these conditions

i need it because I'm implementing timing attack on RSA, and it's needed to generate such number to measure time without modular reduction
Thanks.


Solution

  • If the list of z values is not known in advance you could probably try coroutine for this:

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