def setUp(self): self.tp = ThresholdParameters(3, 5) self.cp = CurveParameters() self.pk, self.shares = central.create_public_key_and_shares_centralized(self.cp, self.tp) self.message = 'Some secret message' self.em = central.encrypt_message(self.message, self.pk) self.reconstruct_shares = [self.shares[i] for i in [0, 2, 4]] # choose 3 of 5 key shares self.partial_decryptions = [participant.compute_partial_decryption(self.em, share) for share in self.reconstruct_shares]
def test_complete_process_without_enough_shares(self): curve_params = CurveParameters() thresh_params = ThresholdParameters(3, 5) pub_key, key_shares = central.create_public_key_and_shares_centralized(curve_params, thresh_params) message = 'Some secret message to be encrypted!' encrypted_message = central.encrypt_message(message, pub_key) reconstruct_shares = [key_shares[i] for i in [3, 4]] # choose 2 of 5 key shares partial_decryptions = [participant.compute_partial_decryption(encrypted_message, share) for share in reconstruct_shares] with self.assertRaises(ThresholdCryptoError): central.decrypt_message(partial_decryptions, encrypted_message, thresh_params)
def test_curve_parameter_json(self): cp = CurveParameters() cp_j = CurveParameters.from_json(cp.to_json()) self.assertEqual(cp, cp_j)
def test_invalid_curve_parameters_whole_group(self): with self.assertRaises(ThresholdCryptoError): CurveParameters(curve_name="invalid-curve")
def test_valid_curve_parameters(self): cp = CurveParameters() self.assertTrue(cp.order > 0)
def setUp(self): self.tp = ThresholdParameters(3, 5) self.cp = CurveParameters() self.message = 'Some secret message'
def test_re_encryption_key_json(self): rek = ReEncryptionKey(key=42, curve_params=CurveParameters()) rek_j = ReEncryptionKey.from_json(rek.to_json()) self.assertEqual(rek, rek_j)