Efficient (HUGE) prime modulus
Peter Otten
__peter__ at web.de
Mon Nov 19 12:13:20 EST 2007
blaine wrote:
> A = (G ** a) % P # G^a mod P
>
> ###### END #####
> The above code takes a very long time. If I make little a only 16 bits
> instead of 512, it takes about 12 seconds on my machine to compute. Is
> this incorrect usage of **? I used math.pow and built-in pow. The
> math.pow complained about converting a long to a float. The built in
> pow() took a very long time as well.
Even in its three-argument form?
"""
pow(...)
pow(x, y[, z]) -> number
With two arguments, equivalent to x**y. With three arguments,
equivalent to (x**y) % z, but may be more efficient (e.g. for longs).
"""
Peter
More information about the Python-list
mailing list