Search in sources :

Example 76 with ECKey

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

the class SampleEthereumSignatureGenerator method main.

public static void main(String[] args) {
    String signedData = "6b2168da-3dff-4e06-b05c-e39f91bd1eae";
    ECKey usersPrivateKey = new ECKey(bytesToBigInteger(Hex.decode("f092460bdfe1229f3c7c70e80a3722dd526b969056700f908e91d9f8178e1464")), CURVE.getCurve().createPoint(bytesToBigInteger(Hex.decode("0F 7E C4 84 DA 6B 82 B5 3B 75 C1 57 30 BD C4 A2 6D 7E 18 43 65 E0 01 50 46 65 A2 C2 E1 82 B8 72")), bytesToBigInteger(Hex.decode("00 8A 4B F8 48 EA F7 9C 4D 7B 3F 30 7E A6 8D B6 55 75 F5 FD D7 F9 8F 65 CD 76 1A E0 27 61 D9 EC F0"))));
    ECKey.ECDSASignature signature = usersPrivateKey.sign(sha3(signedData.getBytes()));
    byte[] signautureAsDer = convertEthereumSignatureToDer(Base64.decode(signature.toBase64()));
    ECKey publicKey = ECKey.fromPublicOnly(usersPrivateKey.getPubKeyPoint());
    System.out.println("Private key: " + Hex.toHexString(usersPrivateKey.getPrivKeyBytes()));
    System.out.println("Public key (65 bytes): " + Hex.toHexString(publicKey.getPubKey()));
    System.out.println("Address: " + Hex.toHexString(publicKey.getAddress()));
    System.out.println("Signature in DER: " + Hex.toHexString(signautureAsDer));
}
Also used : ECKey(org.ethereum.crypto.ECKey)

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