def test_x_one_generation(self): # s(1) is True? i = k + 1, using seed s(0) = 9 bbs = BBS(p=7, q=11, s=9) actual = bbs.next() expected = 4 # calculated by hand self.assertEqual(expected, actual)
def test_x_plus_one_generation(self): # s(i+1) is True by assumption. x = k + 1 # using s(1) = 4 # is s(i+1) = 16? bbs = BBS(p=7, q=11, s=9) bbs.next() actual = bbs.next() expected = 16 # calculated by hand self.assertEqual(expected, actual)
def test_validation_p_is_equal_to_q(self): try: BBS(p=5, q=5, s=3) self.fail('Validation is succeed and no errors') except ValidationError as validation_error: actual = validation_error.errors expected = "p is equal to q" self.assertEqual(expected, actual)
def test_validation_p_and_q_are_prime(self): try: BBS(p=3, q=7, s=3) self.fail('Validation is succeed and no errors') except ValidationError as validation_error: actual = validation_error.errors expected = "p or q are not prime" self.assertEqual(expected, actual)
def test_validation_p_q_both_mod_4_are_3(self): try: BBS(p=7, q=11, s=3) self.fail('Validation is succeed and no errors') except ValidationError as validation_error: actual = validation_error.errors expected = "p or q mod 4 are not 3" self.assertEqual(expected, actual)
def test_validation_s_and_m_are_relatively_prime(self): try: BBS(p=7, q=11, s=8) self.fail('Validation is succeed and no errors') except ValidationError as validation_error: actual = validation_error.errors expected = "(p * q) and s are not relatively prime" self.assertEqual(expected, actual)
def test_validation_s_is_in_range(self): try: BBS(p=7, q=11, s=8) self.fail('Validation is succeed and no errors') except ValidationError as validation_error: actual = validation_error.errors expected = "s is to small or to big" self.assertEqual(expected, actual)
def test_validation_constructor_is_good(self): try: bbs = BBS(p=7, q=11, s=8) RT(bbs) self.fail('Validation is succeed and no errors') except ValidationError as err: actual = err.errors expected = "bbs is not BBS type" self.assertEqual(expected, actual)
def setUp(self): self.__plainbytes = np.random.randint(0, 256, 19, 'B') self.__alice = RT(BBS(p=7, q=11, s=9)) self.__bob = RT(BBS(p=7, q=11, s=9))
def test_decrypt_is_good(self): bbs = BBS(p=7, q=11, s=8) rt = RT(bbs) rt.decrypt(np.zeros(10)) self.assert_(True)