Search in sources :

Example 71 with ECKey

use of org.ethereum.crypto.ECKey in project rskj by rsksmart.

the class Wallet method addAccount.

public RskAddress addAccount(String passphrase) {
    Account account = new Account(new ECKey());
    saveAccount(account, passphrase);
    return account.getAddress();
}
Also used : Account(org.ethereum.core.Account) ECKey(org.ethereum.crypto.ECKey)

Example 72 with ECKey

use of org.ethereum.crypto.ECKey in project account-identity by cryptofiat.

the class EscrowService method createEscrowKey.

public Escrow createEscrowKey(long idCode) {
    ECKey key = new ECKey();
    Escrow escrow = Escrow.builder().privateKey(encUtils.encrypt(ethereumService.hex(key.getPrivKeyBytes()))).address(ethereumService.hex(key.getAddress())).idCode(idCode).build();
    return escrow;
}
Also used : Escrow(eu.cryptoeuro.accountmapper.domain.Escrow) ECKey(org.ethereum.crypto.ECKey)

Example 73 with ECKey

use of org.ethereum.crypto.ECKey in project account-identity by cryptofiat.

the class EthereumService method testSigning.

public void testSigning() throws IOException {
    String addr = "65fa6548764c08c0dd77495b33ed302d0c212691";
    ECKey signer = ECKey.fromPrivate(Hex.decode(without0x("0xc33d80b3fddd6bc5d62498905b90c94cf1252ffd846def3b530acd803bbb3783")));
    signDelegate(0, 3, 1, "65fa6548764c08c0dd77495b33ed302d0c212691", signer);
    WalletServerAccountResponse addrDetails = wsService.getAccount(hex(signer.getAddress()));
    log.info("some info about address" + addrDetails.toString());
}
Also used : WalletServerAccountResponse(eu.cryptoeuro.accountmapper.response.WalletServerAccountResponse) ECKey(org.ethereum.crypto.ECKey)

Example 74 with ECKey

use of org.ethereum.crypto.ECKey in project account-identity by cryptofiat.

the class EthereumService method activateEthereumAccount.

public String activateEthereumAccount(String accountAddress) throws IOException {
    accountAddress = with0x(accountAddress);
    ECKey approver = getAccountApproverKey();
    String txHash = sendTransaction(approver, approveAccountFunction.encode(accountAddress));
    log.info("Account " + accountAddress + " approved by " + hex(approver.getAddress()) + ". TxHash=" + txHash);
    return txHash;
}
Also used : ECKey(org.ethereum.crypto.ECKey)

Example 75 with ECKey

use of org.ethereum.crypto.ECKey in project account-identity by cryptofiat.

the class HDKey method deriveAddressFromKey.

public static HdAddress deriveAddressFromKey(String pubkey, int index) {
    while (index < 1 << 30) {
        try {
            DeterministicKey master = DeterministicKey.deserializeB58(null, pubkey, MainNetParams.get());
            DeterministicKey child = HDKeyDerivation.deriveChildKey(master, index);
            ECKey childkey = ECKey.fromPublicOnly(child.getPubKey());
            HdAddress address = new HdAddress(index, "0x".concat(org.spongycastle.util.encoders.Hex.toHexString(childkey.getAddress())));
            return address;
        } catch (HDDerivationException e) {
            index++;
        }
    }
    throw new RuntimeException("Couldn't generate HD Key after max tries");
}
Also used : HDDerivationException(org.bitcoinj.crypto.HDDerivationException) ECKey(org.ethereum.crypto.ECKey) DeterministicKey(org.bitcoinj.crypto.DeterministicKey)

Aggregations

ECKey (org.ethereum.crypto.ECKey)76 Test (org.junit.Test)43 BigInteger (java.math.BigInteger)17 NodeDistanceTable (co.rsk.net.discovery.table.NodeDistanceTable)10 ArrayList (java.util.ArrayList)10 Node (org.ethereum.net.rlpx.Node)10 InetSocketAddress (java.net.InetSocketAddress)9 Transaction (org.ethereum.core.Transaction)8 BlockGenerator (co.rsk.blockchain.utils.BlockGenerator)7 RepositoryImpl (co.rsk.db.RepositoryImpl)7 SimpleRskTransaction (co.rsk.peg.simples.SimpleRskTransaction)7 Channel (io.netty.channel.Channel)7 org.ethereum.core (org.ethereum.core)7 co.rsk.bitcoinj.core (co.rsk.bitcoinj.core)6 BridgeEventLogger (co.rsk.peg.utils.BridgeEventLogger)6 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 BlockChainBuilder (co.rsk.test.builders.BlockChainBuilder)4 Account (org.ethereum.core.Account)4 RskAddress (co.rsk.core.RskAddress)3