Example #1
0
        public async Task TestEthereumDisplayPublicKey()
        {
            _LedgerManager.SetCoinNumber(60);
            var addressPath = Helpers.GetDerivationPathData(new BIP44AddressPath(_LedgerManager.CurrentCoin.IsSegwit, _LedgerManager.CurrentCoin.CoinNumber, 0, false, 0));
            var publicKey   = await _LedgerManager.SendRequestAsync <EthereumAppGetPublicKeyResponse, EthereumAppGetPublicKeyRequest>(new EthereumAppGetPublicKeyRequest(true, false, addressPath));

            Assert.IsTrue(!string.IsNullOrEmpty(publicKey.PublicKey));
        }
Example #2
0
        protected override async Task <byte[]> GetPublicKeyAsync()
        {
            var path = GetPath();
            var publicKeyResponse = await LedgerManager.SendRequestAsync <EthereumAppGetPublicKeyResponse, EthereumAppGetPublicKeyRequest>(new EthereumAppGetPublicKeyRequest(true, false, path));

            if (publicKeyResponse.IsSuccess)
            {
                return(publicKeyResponse.PublicKeyData);
            }

            throw new Exception(publicKeyResponse.StatusMessage);
        }
Example #3
0
        protected override async Task <ECDSASignature> SignExternallyAsync(byte[] hash)
        {
            var path = GetPath();

            var firstRequest = new EthereumAppSignatureRequest(true, path.Concat(hash).ToArray());

            var response = await LedgerManager.SendRequestAsync <EthereumAppSignatureResponse, EthereumAppSignatureRequest>(firstRequest);

            var signature = ECDSASignatureFactory.FromComponents(response.SignatureR, response.SignatureS);

            signature.V = new BigInteger(response.SignatureV).ToBytesForRLPEncoding();
            return(signature);
        }