private void loadPublicKey() {
try {
String pubKey = “MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEKAsFhBG7oJV7QDV7kh4PEEiBI6FghVPzh0Jiuc0Q/L4ZXRjIh8ZQl6EGUjBEgxz6h8dXe50e+DTotQnSiqs29A==”;
byte[] encoded = Base64.getDecoder().decode(pubKey);
KeyFactory kf = KeyFactory.getInstance(“EC”);
EncodedKeySpec keySpec = new X509EncodedKeySpec(encoded);
publicKey = (ECPublicKey)kf.generatePublic(keySpec);
} catch (Exception e) {
logger.error(“Failed to load public key”, e);
}
}

private void loadPrivateKey() {
try {
String privKey = “MD4CAQAwEAYHKoZIzj0CAQYFK4EEAAoEJzAlAgEBBCAINorlHfu8FSQxtqvBLlk1R04P12uyVjyTY5OTWMX1Zw==”;
byte[] encoded = Base64.getDecoder().decode(privKey);
KeyFactory kf = KeyFactory.getInstance(“EC”);
EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(encoded);
privateKey = (ECPrivateKey)kf.generatePrivate(keySpec);
} catch (Exception e) {
logger.error(“Failed to load private key”, e);
}
}

The public/private key are generated from https://mkjwk.org/

lff l

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store