Beispiel #1
0
 def _genPrime(cls):
     # Generate 2 large primes `p_prime` and `q_prime` and use them
     # to generate another 2 primes `p` and `q` of 1024 bits
     prime = cmod.randomPrime(LARGE_PRIME)
     i = 0
     while not cmod.isPrime(2 * prime + 1):
         prime = cmod.randomPrime(LARGE_PRIME)
         i += 1
     print("In {} iterations, found prime {}".format(i, prime))
     return prime
Beispiel #2
0
def genPrime():
    """
    Generate 2 large primes `p_prime` and `q_prime` and use them
    to generate another 2 primes `p` and `q` of 1024 bits
    """
    prime = cmod.randomPrime(LARGE_PRIME)
    i = 0
    while not cmod.isPrime(2 * prime + 1):
        prime = cmod.randomPrime(LARGE_PRIME)
        i += 1
    return prime
 def _genRhoBGamma(cls):
     while True:
         rho = cmod.randomPrime(LARGE_PUBLIC_RHO)
         b = cmod.randomBits(LARGE_PUBLIC_B)
         Gamma = b * rho + 1
         if cmod.isPrime(Gamma) and (rho % b != 0):
             return rho, b, Gamma