private void RunTestValid(TestGroupTest test)
        {
            ECPublicKeyParameters  publicKey  = KeyParser.ParsePublicKeyDer(Hex.Decode(test.PublicKey));
            ECPrivateKeyParameters privateKey = KeyParser.ParsePrivateKeyHex(test.PrivateKey);

            byte[] expectedSharedSecret = Hex.Decode(test.SharedSecret);
            byte[] sharedSecret         = KeyDerivation.ComputeSharedSecret(privateKey, publicKey);
            Assert.True(sharedSecret.SequenceEqual(expectedSharedSecret));
        }
        private void RunTestInvalid(TestGroupTest test)
        {
            ECPrivateKeyParameters privateKey = KeyParser.ParsePrivateKeyHex(test.PrivateKey);

            byte[] publicKeyBytes = Hex.Decode(test.PublicKey);
            Assert.Throws <ArgumentException>(() =>
            {
                ECPublicKeyParameters publicKey = KeyParser.ParsePublicKeyDer(publicKeyBytes);
                byte[] sharedSecret             = KeyDerivation.ComputeSharedSecret(privateKey, publicKey);
            });
        }
 private void RunTestAcceptable(TestGroupTest test)
 {
     try
     {
         RunTestValid(test);
     }
     catch (Exception e)
     {
         // Assert that Assert.True was not the cause of exception.
         Assert.IsNotType <TrueException>(e);
     }
 }
        private void RunTest(int @base, TestGroupTest test)
        {
            switch (test.Result)
            {
            case "valid":
                RunTestValid(test);
                break;

            case "invalid":
                RunTestInvalid(test);
                break;

            case "acceptable":
                RunTestAcceptable(test);
                break;
            }
        }