Example #1
0
def test0(bitsz):
    #simple: 8b + 8b + 8b = 24b
    #128 DATA + 32 = 160 DATA, 128 RAND, *6
    if type(bitsz) in [int, long]:
        # select a value within the available range for p0
        a = SR().randrange((bitsz * 2) + 2, (bitsz * 3) + 4)
        # attempt to generate a potential p0 of bit size a
        while 1:
            b = SR().getrandbits(a)
            if b.bit_length() == a: break
            #
        # see if b is odd and adjust as necessary
        if b & 1 == 0: b = b + 1
        if b.bit_length() > a: b = b - 2
        # begin testing for primality of b
        # divisible by first 64 primes?
        while 1:
            z = [(b % i) for i in P64]
            if 0 in z: b += 2
            else: break
        # generate mmi after eliminating some composites (above P64)
        r = SR().getrandbits(a // 2)
        c = findmmi(b, r)  # breaks the world
        while 1:
            if type(c) == str:
                b = b + 2
                c = findmmi(
                    b, r)  # infinite loop + processor intensive?! Sign me up!
            #
            if type(c) == long: break
            #
        #
        return a, b, c, r
    return 0