def testModExp(number1, number2, number3): result = hex(pow(number1, number2, number3) & util.bitMask)[2:] return util.test( result, "modexp {0} {1} {2}".format(util.toBigIntString(number1), util.toBigIntString(number2), util.toBigIntString(number3)))
def testSubtract(number1, number2): result = number1 - number2 if result < 0: power = max((len(hex(-result)) // 8 + 1) * 32, 32) result = (1 << power) + result result = hex(result)[2:] # Workaround for bizarre "f" and "0" prefixing. while result[:8] == "f" * 8: result = result[8:] while result[0] == '0': result = result[1:] else: result = hex(result)[2:] return util.test( result, "subtract {0} {1}".format(util.toBigIntString(number1), util.toBigIntString(number2)))
def testXor(number1, number2): result = hex((number1 ^ number2) & util.bitMask)[2:] return util.test( result, "xor {0} {1}".format(util.toBigIntString(number1), util.toBigIntString(number2)))
def testLShift(number, shiftBy): assert (shiftBy >= 0) result = hex((number << shiftBy) & util.bitMask)[2:] nString = util.toBigIntString(number) return util.test(result, "lshift {0} {1}".format(nString, shiftBy))
def testAnd(number1, number2): result = hex((number1 & number2) & util.bitMask)[2:] return util.test( result, "and {0} {1}".format(util.toBigIntString(number1), util.toBigIntString(number2)))
def testRShift(number, shiftBy): assert (shiftBy >= 0) result = hex(number >> shiftBy)[2:] nString = util.toBigIntString(number) return util.test(result, "rshift {0} {1}".format(nString, shiftBy))
def testDivide(number1, number2): result = hex((number1 // number2) & util.bitMask)[2:] return util.test( result, "divide {0} {1}".format(util.toBigIntString(number1), util.toBigIntString(number2)))
def testMultiply(number1, number2): result = hex((number1 * number2) & util.bitMask)[2:] return util.test( result, "multiply {0} {1}".format(util.toBigIntString(number1), util.toBigIntString(number2)))
def testMiller(number): result = str(millerRabin(number, 20)) return util.test(result, "prime {0}".format(util.toBigIntString(number)))
def testAssign(number): result = hex(number)[2:] nString = util.toBigIntString(number) return util.test(result, "assign {0}".format(nString))