server/lib/rsa/_version200.py 1 location
|
@@ 231-240 (lines=10) @@
|
228 |
|
if a == 0: return 0 |
229 |
|
return result |
230 |
|
|
231 |
|
def jacobi_witness(x, n): |
232 |
|
"""Returns False if n is an Euler pseudo-prime with base x, and |
233 |
|
True otherwise. |
234 |
|
""" |
235 |
|
|
236 |
|
j = jacobi(x, n) % n |
237 |
|
f = pow(x, (n-1)/2, n) |
238 |
|
|
239 |
|
if j == f: return False |
240 |
|
return True |
241 |
|
|
242 |
|
def randomized_primality_testing(n, k): |
243 |
|
"""Calculates whether n is composite (which is always correct) or |
server/lib/rsa/prime.py 1 location
|
@@ 55-64 (lines=10) @@
|
52 |
|
if a == 0: return 0 |
53 |
|
return result |
54 |
|
|
55 |
|
def jacobi_witness(x, n): |
56 |
|
"""Returns False if n is an Euler pseudo-prime with base x, and |
57 |
|
True otherwise. |
58 |
|
""" |
59 |
|
|
60 |
|
j = jacobi(x, n) % n |
61 |
|
f = pow(x, (n - 1) // 2, n) |
62 |
|
|
63 |
|
if j == f: return False |
64 |
|
return True |
65 |
|
|
66 |
|
def randomized_primality_testing(n, k): |
67 |
|
"""Calculates whether n is composite (which is always correct) or |