@@ -349,17 +349,19 @@ def y_from_x(x, p, q, n, sign):
349349
350350
351351if __name__ == "__main__" :
352- import rsa
352+ from Crypto .Random .random import randint
353+ from Crypto .Util .number import getPrime
353354 import time
354355
355356 t = time .time ()
356- n = rsa .get_prime (256 / 8 , 20 )
357+ n = getPrime (int (256 / 8 ))
358+ #n = rsa.get_prime(256 / 8, 20)
357359 tp = time .time () - t
358- p = rsa . random . randint (1 , n )
359- p1 = (rsa . random . randint (1 , n ), rsa . random . randint (1 , n ))
360+ p = randint (1 , n )
361+ p1 = (randint (1 , n ), randint (1 , n ))
360362 q = curve_q (p1 [0 ], p1 [1 ], p , n )
361- r1 = rsa . random . randint (1 , n )
362- r2 = rsa . random . randint (1 , n )
363+ r1 = randint (1 , n )
364+ r2 = randint (1 , n )
363365 q1 = mulp (p , q , n , p1 , r1 )
364366 q2 = mulp (p , q , n , p1 , r2 )
365367 s1 = mulp (p , q , n , q1 , r2 )
@@ -368,14 +370,15 @@ def y_from_x(x, p, q, n, sign):
368370 tt = time .time () - t
369371
370372 def test (tcount , bits = 256 ):
371- n = rsa .get_prime (bits / 8 , 20 )
372- p = rsa .random .randint (1 , n )
373- p1 = (rsa .random .randint (1 , n ), rsa .random .randint (1 , n ))
373+ n = getPrime (int (bits / 8 ))
374+ #n = rsa.get_prime(bits / 8, 20)
375+ p = randint (1 , n )
376+ p1 = (randint (1 , n ), randint (1 , n ))
374377 q = curve_q (p1 [0 ], p1 [1 ], p , n )
375- p2 = mulp (p , q , n , p1 , rsa . random . randint (1 , n ))
378+ p2 = mulp (p , q , n , p1 , randint (1 , n ))
376379
377- c1 = [rsa . random . randint (1 , n ) for i in range (tcount )]
378- c2 = [rsa . random . randint (1 , n ) for i in range (tcount )]
380+ c1 = [randint (1 , n ) for i in range (tcount )]
381+ c2 = [randint (1 , n ) for i in range (tcount )]
379382 c = list (zip (c1 , c2 ))
380383
381384 t = time .time ()
0 commit comments