public static string getPublicKeyFromPrivateKeyEx(string privateKey)
        {
            var curve  = SecNamedCurves.GetByName("secp256k1");
            var domain = new ECDomainParameters(curve.Curve, curve.G, curve.N, curve.H);

            var d = new Org.BouncyCastle.Math.BigInteger(privateKey);
            var q = domain.G.Multiply(d);

            var publicKey = new ECPublicKeyParameters(q, domain);

            return(Base58Encoding.encode(publicKey.Q.GetEncoded()));
        }
        public static string getSignature(string privateKey, string message)
        {
            var curve  = SecNamedCurves.GetByName("secp256k1");
            var domain = new ECDomainParameters(curve.Curve, curve.G, curve.N, curve.H);

            var keyParameters = new
                                ECPrivateKeyParameters(new Org.BouncyCastle.Math.BigInteger(privateKey),
                                                       domain);

            ISigner signer = SignerUtilities.GetSigner("SHA-256withECDSA");

            signer.Init(true, keyParameters);
            signer.BlockUpdate(Encoding.ASCII.GetBytes(message), 0, message.Length);
            var signature = signer.GenerateSignature();

            return(Base58Encoding.encode(signature));
        }
        public static bool verifySignature(string message, string publicKey, string signature)
        {
            var curve  = SecNamedCurves.GetByName("secp256k1");
            var domain = new ECDomainParameters(curve.Curve, curve.G, curve.N, curve.H);

            var publicKeyBytes = Base58Encoding.decode(publicKey);

            var q = curve.Curve.DecodePoint(publicKeyBytes);

            var keyParameters = new
                                Org.BouncyCastle.Crypto.Parameters.ECPublicKeyParameters(q,
                                                                                         domain);

            ISigner signer = SignerUtilities.GetSigner("SHA-256withECDSA");

            signer.Init(false, keyParameters);
            signer.BlockUpdate(Encoding.ASCII.GetBytes(message), 0, message.Length);

            var signatureBytes = Base58Encoding.decode(signature);

            return(signer.VerifySignature(signatureBytes));
        }