def test_MulModHex(test_data_dir): # Reading test data from the file with open(test_data_dir / "testData_MulModHex", "r") as mulModHex_txt: for x in mulModHex_txt: hexNumber = x.split(",") # Multiply modulo of big numbers of arbitrary precision in hex actual_Value = PyBigNumbers.Mul_mod_Hex(hexNumber[0], hexNumber[1], hexNumber[2]) expected_Value = hexNumber[3].rstrip("\n") # Verifying the actual value with expected value assert actual_Value.lstrip( "0") == expected_Value.upper(), "Test failed"
def __mul__(self, obj): if (self.isDec): if (self.mod is None): prodVal = PyBigNumbers.multiplyFromDec(self.value, obj.value) else: #print ('%s * %s mod %s' % (self.value, obj.value, self.mod)) prodVal = PyBigNumbers.Mul_mod_Dec(self.value, obj.value, self.mod) retVal = BigNum(prodVal, self.mod, self.isDec) return retVal else: if (self.mod is None): prodVal = PyBigNumbers.multiplyFromHex(self.value, obj.value) else: #print ('%s * %s mod %s' % (self.value, obj.value, self.mod)) prodVal = PyBigNumbers.Mul_mod_Hex(self.value, obj.value, self.mod) retVal = BigNum(prodVal, self.mod, self.isDec) return retVal