inkfish/create_discriminant.py
def create_discriminant(seed, length=2048):
    """
    Return a discriminant of the given length using the given seed.
    Generate a probable prime p where p % 8 == 7.
    Return -p.
    """
    extra = length % 8
    entropy = entropy_from_seed(seed, (length >> 3) + (2 if extra == 0 else 3))
    n = (int.from_bytes(entropy[:-2], 'big') >> (0 if extra == 0 else 8 - extra)) | (1 << (length - 1))
    n -= n % m
    n += residues[int.from_bytes(entropy[-2:], 'big') % len(residues)]

    # Find the smallest prime >= n of the form n + m*x
    while True:
        # we set up "sieve" so it's "True" for known composite numbers
        sieve = [False] * (1 << 16)  # Store m*i as i
        for p, q in sieve_info:
            # q = m^-1 (mod p)
            # i = -n / m, so that m*i is -n (mod p).
            i = ((-n % p) * q) % p
            while i < len(sieve):
                sieve[i] = True
                i += p

        for i, x in enumerate(sieve):
            if not x and is_probable_prime(n + m*i):
                return -(n + m*i)
        n += m * (1 << 16)

    Return a discriminant of the given length using the given seed.
    Generate a probable prime p where p % 8 == 7.
    Return -p.
    
Return a discriminant of the given length using the given seed.
Generate a probable prime p where p % 8 == 7.
Return -p.
Return a discriminant of the given length using the given seed . Generate a probable prime p where p % 8 == 7 . Return - p .
def create_discriminant(seed, length=2048):
    extra = length % 8
    entropy = entropy_from_seed(seed, (length >> 3) + (2 if extra == 0 else 3))
    n = (int.from_bytes(entropy[:-2], 'big') >> (0 if extra == 0 else 8 - extra)) | (1 << (length - 1))
    n -= n % m
    n += residues[int.from_bytes(entropy[-2:], 'big') % len(residues)]
    while True:
        sieve = [False] * (1 << 16)  
        for p, q in sieve_info:
            i = ((-n % p) * q) % p
            while i < len(sieve):
                sieve[i] = True
                i += p
        for i, x in enumerate(sieve):
            if not x and is_probable_prime(n + m*i):
                return -(n + m*i)
        n += m * (1 << 16)
def create_discriminant ( seed , length = 2048 ) : extra = length % 8 entropy = entropy_from_seed ( seed , ( length >> 3 ) + ( 2 if extra == 0 else 3 ) ) n = ( int . from_bytes ( entropy [ : - 2 ] , 'big' ) >> ( 0 if extra == 0 else 8 - extra ) ) | ( 1 << ( length - 1 ) ) n -= n % m n += residues [ int . from_bytes ( entropy [ - 2 : ] , 'big' ) % len ( residues ) ] while True : sieve = [ False ] * ( 1 << 16 ) for p , q in sieve_info : i = ( ( - n % p ) * q ) % p while i < len ( sieve ) : sieve [ i ] = True i += p for i , x in enumerate ( sieve ) : if not x and is_probable_prime ( n + m * i ) : return - ( n + m * i ) n += m * ( 1 << 16 )
Return a discriminant of the given length using the given seed.
Return a discriminant of the given length using the given seed .
"""
    Return a discriminant of the given length using the given seed.
    Generate a probable prime p where p % 8 == 7.
    Return -p.
    """ # Find the smallest prime >= n of the form n + m*x # we set up "sieve" so it's "True" for known composite numbers # Store m*i as i # q = m^-1 (mod p) # i = -n / m, so that m*i is -n (mod p).
seed
length