As per https://crypto.stackexchange.com/questions/18105/how-does-recovering-the-public-key-from-an-ecdsa-signature-work, I should be able to recover an ECDSA public key if I have a signature and the message it is signing. Are there any examples as to how to get this information using BouncyCastle and Java? If not, could someone walk me through the basics of how to implement it?
If it helps, this is how I'm signing the message:
public static String signData(PrivateKey privateKey, String in) {
Security.addProvider(new BouncyCastleProvider());
String out;
Signature sig;
try {
sig = Signature.getInstance("SHA256withECDSA","BC");
sig.initSign(privateKey);
byte[] inBytes = in.getBytes();
sig.update(inBytes);
byte[] sigFinal = sig.sign();
out = getHex(sigFinal);
} catch (Exception e) {
throw new RuntimeException(e);
}
return out;
}
I guess my biggest issue is I don't know how java Signatures are encoded and outputted. If anyone could shed any light on that it would be appreciated.