Exemplo n.º 1
0
        public async Task <EthECDSASignature> SignAndCalculateVAsync(byte[] hash, BigInteger chainId)
        {
            var signature = await _ethExternalSigner.SignAsync(hash);

            if (_ethExternalSigner.CalculatesV)
            {
                return(new EthECDSASignature(signature));
            }

            var publicKey = await _ethExternalSigner.GetPublicKeyAsync();

            var recId  = EthECKey.CalculateRecId(signature, hash, publicKey);
            var vChain = EthECKey.CalculateV(chainId, recId);

            signature.V = vChain.ToBytesForRLPEncoding();
            return(new EthECDSASignature(signature));
        }
Exemplo n.º 2
0
        public async Task <EthECDSASignature> SignAsync(byte[] rawBytes, BigInteger chainId)
        {
            var signature = await SignExternallyAsync(rawBytes).ConfigureAwait(false);

            if (CalculatesV)
            {
                return(new EthECDSASignature(signature));
            }

            var publicKey = await GetPublicKeyAsync().ConfigureAwait(false);

            var recId  = EthECKey.CalculateRecId(signature, rawBytes, publicKey);
            var vChain = EthECKey.CalculateV(chainId, recId);

            signature.V = vChain.ToBytesForRLPEncoding();
            return(new EthECDSASignature(signature));
        }