public static byte[] ECDHKeyExchange(Uri URL, string Endpoint = "") { byte[] key = default(byte[]); using (ECDiffieHellmanCng AsymAlgo = new ECDiffieHellmanCng()) { var publicKey = AsymAlgo.PublicKey.ToXmlString(); byte[] r = Comms.HttpPost(URL, Endpoint, Encoding.UTF8.GetBytes(publicKey)); ECDiffieHellmanCngPublicKey peerPublicKey = ECDiffieHellmanCngPublicKey.FromXmlString(Encoding.UTF8.GetString(r)); key = AsymAlgo.DeriveKeyMaterial(peerPublicKey); } return(key); }