Example #1
0
        /**
         * Signs a transaction with the given signingKey (which is an Elliptic keypair
         * object that contains a private key). The signature is then stored inside the
         * transaction object and later stored on the blockchain.
         *
         * @param {string} signingKey
         */
        public bool SignTransaction(string signingKey, out string error)
        {
            try
            {
                error = null;
                var encryptResult = CryptoKeyUtility.GenerateKeyFromString(signingKey, out error);

                if (encryptResult == null)
                {
                    throw new Exception(error);
                }

                this.signature  = encryptResult.Item1;
                this.encryptKey = encryptResult.Item2;
                this.initVector = encryptResult.Item3;

                return(true);
            }
            catch (Exception ex)
            {
                error           = ex.Message;
                this.signature  = null;
                this.encryptKey = null;
                this.initVector = null;
                return(false);
            }
        }