public virtual string HashAndSign(byte[] plainMessage, CfxECKey key)
        {
            var hash      = Hash(plainMessage);
            var signature = key.SignAndCalculateV(hash);

            return(CreateStringSignature(signature));
        }
Example #2
0
        public string sign(byte[] privateKey, dynamic chainId)
        {
            this.storageLimit = BitConverter.GetBytes(100000).Clear();

            this.chianId = BitConverter.GetBytes((int)chainId).Clear();
            //this.Gas = BitConverter.GetBytes(2000000).Clear();
            List <byte[]> raw = new List <byte[]> {
                this._nonce, this.GasPrice, this.Gas, this.to,
                this.Value, this.storageLimit, this._epochHeight, this.chianId, this.Data
            };

            var x1 = rlpEncode(raw).ToHex();
            var x2 = sha3Keccack.CalculateHash(rlpEncode(raw));//sha3
            var k  = new CfxECKey("0x" + privateKey.ToHex());
            var x3 = k.SignAndCalculateV(x2);
            //x3.V = new byte[] { 0x01 };

            List <object> rawWithRSV = new List <object> {
                raw, x3.V, x3.R, x3.S
            };
            var x4 = rlpEncode(rawWithRSV).ToHex();

            return("0x" + x4);
        }
Example #3
0
 public void Sign(CfxECKey key, BigInteger chainId)
 {
     Signature        = key.SignAndCalculateV(RawHash, chainId);
     rlpSignedEncoded = null;
 }
Example #4
0
 public void Sign(CfxECKey key)
 {
     Signature        = key.SignAndCalculateV(RawHash);
     rlpSignedEncoded = null;
 }
        public virtual string Sign(byte[] message, CfxECKey key)
        {
            var signature = key.SignAndCalculateV(message);

            return(CreateStringSignature(signature));
        }