Skip to content

Instantly share code, notes, and snippets.

View jlmcdonnell's full-sized avatar

John McDonnell jlmcdonnell

  • Dallas, TX
View GitHub Profile
@nakov
nakov / ECDSA-secp256k1-example.java
Last active July 21, 2023 09:37
ECDSA with secp256k1 in Java: generate ECC keys, sign, verify
import org.bouncycastle.util.encoders.Hex;
import org.web3j.crypto.*;
import java.math.BigInteger;
public class ECCExample {
public static String compressPubKey(BigInteger pubKey) {
String pubKeyYPrefix = pubKey.testBit(0) ? "03" : "02";
String pubKeyHex = pubKey.toString(16);
String pubKeyX = pubKeyHex.substring(0, 64);