This library is an Android-friendly redistribution of ether.camp's ethereumj. It depends on SpongyCastle to provide a comprehensive security implementation suitable for generating and operating on Ethereum-compatible private keys.
package your.package.id;
import java.security.Security;
import java.security.SecureRandom;
import org.spongycastle.util.encoders.Hex;
import org.spongycastle.jce.provider.BouncyCastleProvider;
import za.co.io.ethereumj_android.crypto.ECKey;
class YourClass {
static {
Security.insertProviderAt(new BouncyCastleProvider(), 1);
}
public static void main(String[] args) {
ECKey eck = new ECKey(Security.getProvider("SC"), new SecureRandom());
System.out.println("Private key: " + Hex.toHexString(eck.getPrivKeyBytes()));
System.out.println("Public key: " + Hex.toHexString(eck.getPubKey()));
System.out.println("Address: " + ("0x" + Hex.toHexString(ECKey.computeAddress(eck.getPubKey()))));
}
}
- Shouldn't ethereumj have been named jthereum? 🤔
ethereumj is distributed under the MIT license by ether.camp (LICENSE)