Example #1
0
    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)
Example #2
0
    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)
Example #3
0
 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)
Example #4
0
 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)