/// <summary> /// Encodes the specified private key. /// </summary> /// <param name="privateKey">The private key.</param> /// <param name="publicKey">The pub key.</param> /// <param name="msg">The MSG.</param> /// <param name="iv">The iv.</param> /// <param name="salt">The salt.</param> /// <returns>System.String.</returns> internal static string _Encode(byte[] privateKey, byte[] publicKey, string msg, byte[] iv, byte[] salt) { var shared = new byte[32]; Ed25519Operations.key_derive( shared, salt, privateKey, publicKey); return(salt.ToHexLower() + AesEncryptor(shared, iv, msg)); }
/// <summary> /// Decodes the specified private key. /// </summary> /// <param name="privateKey">The private key.</param> /// <param name="publicKey">The pub key.</param> /// <param name="data">The data.</param> /// <returns>System.String.</returns> internal static string _Decode(byte[] privateKey, byte[] publicKey, byte[] data) { var salt = data.Take(0, 32).ToArray(); var iv = data.Take(32, 16); var payload = data.Take(48, data.Length - 48); var shared = new byte[32]; Ed25519Operations.key_derive( shared, salt, privateKey, publicKey); return(AesDecryptor(shared, iv, payload)); }