diff --git a/BuildingBlocks/src/Crypto/Implementations/LibsodiumSymmetricEncrypter.cs b/BuildingBlocks/src/Crypto/Implementations/LibsodiumSymmetricEncrypter.cs index 82ac9abf81..3a6e666e60 100644 --- a/BuildingBlocks/src/Crypto/Implementations/LibsodiumSymmetricEncrypter.cs +++ b/BuildingBlocks/src/Crypto/Implementations/LibsodiumSymmetricEncrypter.cs @@ -10,7 +10,7 @@ namespace Backbone.Crypto.Implementations; public class LibsodiumSymmetricEncrypter : ISymmetricEncrypter { - public static byte[] DecryptXChaCha20Poly1305(byte[] body, string serializedSecret) + public static byte[] DecryptXChaCha20Poly1305(byte[] body, byte[] key) { var bodyString = Encoding.UTF8.GetString(body); var deserializedBody = JsonSerializer.Deserialize(bodyString, @@ -22,11 +22,6 @@ public static byte[] DecryptXChaCha20Poly1305(byte[] body, string serializedSecr var payload = Convert.FromBase64String(cipherText); var nonce = Convert.FromBase64String(deserializedBody.nnc); - var deserializedSecret = JsonSerializer.Deserialize(serializedSecret, - new JsonSerializerOptions { Converters = { new UrlSafeBase64ToByteArrayJsonConverter() } }); - - var key = Convert.FromBase64String(deserializedSecret!.key + "="); - return DecryptXChaCha20Poly1305(payload, nonce, key); } @@ -71,7 +66,7 @@ public ConvertibleString Decrypt(ConvertibleString encryptedMessage, Convertible ArgumentNullException.ThrowIfNull(key); var body = encryptedMessage.BytesRepresentation; - var serializedSecret = key.Utf8Representation; + var serializedSecret = key.BytesRepresentation; try {