Beispiel #1
0
        public KeyPair LoadFromPrivate(string privKey)
        {
            var ethEcKey = new Nethereum.Signer.EthECKey(privKey);

            return(new KeyPair()
            {
                Address = ethEcKey.GetPublicAddress(),
                Private = ethEcKey.GetPrivateKey()
            });
        }
Beispiel #2
0
        public virtual string GetAddress(long aIndex)
        {
            var lKey     = new Nethereum.Signer.EthECKey(GetIndexKey(aIndex)); // may need to fix this to support the new keygen
            var lWallet  = new Nethereum.HdWallet.Wallet(HexStringToByteArray(GetIndexKey(0)));
            var lAddress = lWallet.GetAccount((int)aIndex).Address;            // do not lower case as it has checksum

            if (!FAddresses.ContainsKey(lAddress.ToLower()))                   // lowercase here for look up
            {
                FAddresses.Add(lAddress.ToLower(), aIndex);
            }
            return(lAddress);
        }
Beispiel #3
0
        /// <summary>
        /// Decrypt and setup wallet from Keystore
        /// </summary>
        /// <param name="PK">Password</param>
        /// <returns>The Wallet</returns>
        public WalletData importFromKeyStore(string keyStore, string password)
        {
            var service = new Nethereum.KeyStore.KeyStoreService();
            var key     = new Nethereum.Signer.EthECKey(
                service.DecryptKeyStoreFromJson(password, keyStore),
                true);

            var address = EthECKey.GetPublicAddress(key.GetPrivateKey());

            _wallet = new WalletData {
                address = address, PK = key.GetPrivateKey()
            };
            _web3 = new Web3(new Nethereum.Web3.Accounts.Account(_wallet.PK), NodeUrl);
            return(_wallet);
        }
Beispiel #4
0
        /// <summary>
        /// Decrypt and setup wallet from Keystore
        /// </summary>
        /// <param name="keyStore">Encrypted Keystore</param>
        /// <param name="password">Password used on encryption</param>
        /// <returns>The Wallet</returns>
        public WalletData importFromKeyStore(string keyStore, string password)
        {
            var service = new Nethereum.KeyStore.KeyStoreService();
            var key     = new Nethereum.Signer.EthECKey(
                service.DecryptKeyStoreFromJson(password, keyStore),
                true);

            var address = EthECKey.GetPublicAddress(key.GetPrivateKey());

            _wallet = new WalletData {
                address = address, PK = key.GetPrivateKey()
            };
            _web3 = new Web3(new Nethereum.Web3.Accounts.Account(_wallet.PK, _chainId), _nodeUrl);
            _paymentChannelsContract = _web3.Eth.GetContract(PaymentChannelsABI, _paymentChannelsContractAddress);
            _validatorsContract      = _web3.Eth.GetContract(ValidatorsABI, _validatorsContractAddress);
            return(_wallet);
        }
Beispiel #5
0
        public virtual string EcRecover(byte[] hashMessage, string signature)
        {
            var ecdaSignature = ExtractEcdsaSignature(signature);

            return(EthECKey.RecoverFromSignature(ecdaSignature, hashMessage).GetPublicAddress());
        }
Beispiel #6
0
        public virtual string Sign(byte[] message, EthECKey key)
        {
            var signature = key.SignAndCalculateV(message);

            return(CreateStringSignature(signature));
        }
Beispiel #7
0
 public virtual EthECDSASignature SignAndCalculateV(byte[] message, EthECKey key)
 {
     return(key.SignAndCalculateV(message));
 }
 public override void Sign(EthECKey key)
 {
     SimpleRlpSigner.SignLegacy(key);
 }
Beispiel #9
0
 public void Sign(EthECKey key, BigInteger chainId)
 {
     Signature        = key.SignAndCalculateV(RawHash, chainId);
     rlpSignedEncoded = null;
 }
Beispiel #10
0
 public void Sign(EthECKey key)
 {
     Signature        = key.SignAndCalculateV(RawHash);
     rlpSignedEncoded = null;
 }
Beispiel #11
0
 private BigInteger GetChainFromVChain()
 {
     return(EthECKey.GetChainFromVChain(Signature.V.ToBigIntegerFromRLPDecoded()));
 }
Beispiel #12
0
 public override void Sign(EthECKey key)
 {
     SimpleRlpSigner.Sign(key, GetChainIdAsBigInteger());
 }