def encrypt_message(self, secret_key, message):
     converted_message = self.__convert_message(message)
     M_1, M_2 = self.__create_message_sub_matrices(secret_key,
                                                   converted_message)
     R = EncryptionHelper.generate_random_square_matrix(
         EncryptionHelper.get_N_squared())
     M_final = np.matrix(np.bmat([[M_1, R], [np.zeros([2, 2]), M_2]]))
     return np.matrix((secret_key[2].dot(M_final)).dot(secret_key[3]))
Ejemplo n.º 2
0
 def __generate_sub_matrices(self):
     k1 = EncryptionHelper.create_modular_inverse_matrix(
         EncryptionHelper.get_N_squared())
     k2, k3, k4 = (EncryptionHelper.generate_random_square_matrix(
         EncryptionHelper.get_N_squared()) for i in range(3))
     return k1, k2, k3, k4