Example #1
0
        public Transaction Sign(ECKeyPair key)
        {
            var hash = Hash.Blake2B(RlpDataForSignature);

            var sig = ECDSASign.SignMessage(hash, key, false);

            var sigBytes = sig.ToByteArray();

            signature = sigBytes.ToHex(true);

            var signer = key.GetRawAddress();

            byte[] concatenatedBytes = new byte[52];
            Unsafe.CopyBlock(ref concatenatedBytes[0], ref hash[0], (uint)hash.Length);
            Unsafe.CopyBlock(ref concatenatedBytes[hash.Length], ref signer[0], (uint)signer.Length);

            byte[] txIdBytes = Hash.Blake2B(concatenatedBytes);
            id = txIdBytes.ToHex(true);

            return(this);
        }