public void ValidateEcdhKeysSharedKeyGenerationForPrivateKeyTest(string aliceKeyStr, string bobKeyStr, string expectedSharedStr) { BigInteger aliceKey = new BigInteger(aliceKeyStr.Replace("L", "")); BigInteger bobKey = new BigInteger(bobKeyStr.Replace("L", "")); var aliceConverted = aliceKey.ToByteArray().ToHex(true); var bobConverted = bobKey.ToByteArray().ToHex(true); ECDH_Key alice = ECDH_Key.ImportKey(aliceConverted); ECDH_Key bob = ECDH_Key.ImportKey(bobConverted); var shared1 = alice.GenerateSharedSecretHex(bob.PublicKey); var shared2 = bob.GenerateSharedSecretHex(alice.PublicKey); var res = new BigInteger(shared1.HexToByteArray()).ToString(); Assert.Equal(shared1, shared2); Assert.Equal(expectedSharedStr.Replace("L", ""), res); testOutputHelper.WriteLine(shared1); testOutputHelper.WriteLine(shared2); testOutputHelper.WriteLine(res); EthECKey aliceKeyEth = new EthECKey(aliceConverted); EthECKey bobKeyEth = new EthECKey(bob.PublicKey.HexToByteArray(), false); var shared3 = aliceKeyEth.CalculateCommonSecret(bobKeyEth).ToHex(true); testOutputHelper.WriteLine(shared3); Assert.Equal(shared1, shared3); }