def test_cipher_encrypt(): dealer = Dealer(p256, n_participants, s_secrets, access_structures) dealer.cipher_generate_keys() # Encrypt number input = 299 key = dealer.cipher_keys[0] ciphertext = dealer.cipher_encrypt(input, key) assert_equal(len(ciphertext), Dealer.AES_BLOCK_SIZE)
def test_cipher_decrypt(): dealer = Dealer(p256, n_participants, s_secrets, access_structures) dealer.cipher_generate_keys() test_input = 'Test message' ciphertext = dealer.cipher_encrypt(test_input, dealer.cipher_keys[-1]) assert_equal(len(ciphertext), Dealer.AES_BLOCK_SIZE) plaintext = dealer.cipher_decrypt(ciphertext, dealer.cipher_keys[-1]) print('type of decrypted plaintext', type(plaintext)) assert_equal(plaintext.decode('utf-8'), test_input) # decrypted data has type bytes