java.security.PublicKey#getEncoded()
returns X509 representation of key which in case of ECC adds a lot of overhead compared to raw ECC values.
I\'d lik
Here is a BouncyCastle approach I've used to unpack the public key:
public static byte[] extractData(final @NonNull PublicKey publicKey) {
final SubjectPublicKeyInfo subjectPublicKeyInfo =
SubjectPublicKeyInfo.getInstance(publicKey.getEncoded());
final byte[] encodedBytes = subjectPublicKeyInfo.getPublicKeyData().getBytes();
final byte[] publicKeyData = new byte[encodedBytes.length - 1];
System.arraycopy(encodedBytes, 1, publicKeyData, 0, encodedBytes.length - 1);
return publicKeyData;
}