@@ -696,6 +696,34 @@ def test_hex(self):
696696 v1 , =  self .Integers (0x10 )
697697 self .assertEqual (hex (v1 ), "0x10" )
698698
699+  def  test_mult_modulo_bytes (self ):
700+  modmult  =  self .Integer ._mult_modulo_bytes 
701+ 
702+  res  =  modmult (4 , 5 , 19 )
703+  self .assertEqual (res , b'\x01 ' )
704+ 
705+  res  =  modmult (4  -  19 , 5 , 19 )
706+  self .assertEqual (res , b'\x01 ' )
707+ 
708+  res  =  modmult (4 , 5  -  19 , 19 )
709+  self .assertEqual (res , b'\x01 ' )
710+ 
711+  res  =  modmult (4  +  19 , 5 , 19 )
712+  self .assertEqual (res , b'\x01 ' )
713+ 
714+  res  =  modmult (4 , 5  +  19 , 19 )
715+  self .assertEqual (res , b'\x01 ' )
716+ 
717+  modulus  =  2 ** 512  -  1  # 64 bytes 
718+  t1  =  13 ** 100 
719+  t2  =  17 ** 100 
720+  expect  =  b"\xfa \xb2 \x11 \x87 \xc3 (y\x07 \xf8 \xf1 n\xde pq\x0b \xca \xf3 \xd3 B,\xef \xf2 \xfb f\xcc )\x8d Z*\x95 \x98 r\x96 \xa8 \xd5 \xc3 }\xe2 q:\xa2 'z\xf4 8\xde %\xef \t \x07 \xbc \xc4 [C\x8b UE2\x90 \xef \x81 \xaa :\x08 " 
721+  self .assertEqual (expect , modmult (t1 , t2 , modulus ))
722+ 
723+  self .assertRaises (ZeroDivisionError , modmult , 4 , 5 , 0 )
724+  self .assertRaises (ValueError , modmult , 4 , 5 , - 1 )
725+  self .assertRaises (ValueError , modmult , 4 , 5 , 4 )
726+ 
699727
700728class  TestIntegerInt (TestIntegerBase ):
701729
0 commit comments