def random_mpz(cls, n_bits): low = 2**(n_bits-1) high = low * 2 # increment and find a prime # return randrange(low, high) return number.getRandomNumber(n_bits, cls.RAND.get_bytes)
def random_mpz(cls, n_bits): low = 2**(n_bits - 1) high = low * 2 # increment and find a prime # return randrange(low, high) return number.getRandomNumber(n_bits, cls.RAND.get_bytes)
def random_mpz_lt(cls, max): # return randrange(0, max) n_bits = int(math.floor(math.log(max, 2))) return (number.getRandomNumber(n_bits, cls.RAND.get_bytes) % max)