diff --git a/lib/cryppo.ex b/lib/cryppo.ex index 2247295..230f44a 100644 --- a/lib/cryppo.ex +++ b/lib/cryppo.ex @@ -288,13 +288,10 @@ defmodule Cryppo do def load(serialized) when is_binary(serialized) do case String.split(serialized, ".") do ["Sign", "Rsa4096", signature, data] -> - with {:ok, sig} <- RsaSignature.load(signature, data), do: {:ok, sig} + RsaSignature.load(signature, data) [strategy_name, encrypted_data, encryption_artefacts] -> - with {:ok, encrypted_data} <- - EncryptedData.load(strategy_name, encrypted_data, encryption_artefacts) do - {:ok, encrypted_data} - end + EncryptedData.load(strategy_name, encrypted_data, encryption_artefacts) [ strategy, @@ -303,15 +300,13 @@ defmodule Cryppo do key_derivation_strategy, derivation_artefacts ] -> - with {:ok, encrypted_data_with_derived_key} <- - EncryptedDataWithDerivedKey.load( - strategy, - encrypted_data, - encryption_artefacts, - key_derivation_strategy, - derivation_artefacts - ), - do: {:ok, encrypted_data_with_derived_key} + EncryptedDataWithDerivedKey.load( + strategy, + encrypted_data, + encryption_artefacts, + key_derivation_strategy, + derivation_artefacts + ) _ -> {:error, :invalid_serialization_value} diff --git a/lib/cryppo/encrypted_data_with_derived_key.ex b/lib/cryppo/encrypted_data_with_derived_key.ex index 19de2c7..d9af32b 100644 --- a/lib/cryppo/encrypted_data_with_derived_key.ex +++ b/lib/cryppo/encrypted_data_with_derived_key.ex @@ -69,9 +69,7 @@ defmodule Cryppo.EncryptedDataWithDerivedKey do derived_key: %DerivedKey{} = derived_key, encrypted_data: %EncryptedData{} = encrypted_data }) do - [encrypted_data, derived_key] - |> Enum.map(fn v -> Serialization.serialize(v) end) - |> Enum.join(".") + [encrypted_data, derived_key] |> Enum.map_join(".", &Serialization.serialize/1) end end end