Given a private key, I can get the uncompressed or compressed version of the public key like so.
EC_KEY* pKey = EC_KEY_new_by_curve_name(NID_secp256k1);
std::vector<unsigned char> getPubKey(EC_KEY* pKey, bool compressed) const {
if (compressed)
EC_KEY_set_conv_form(pKey, POINT_CONVERSION_COMPRESSED);
else
EC_KEY_set_conv_form(pKey, POINT_CONVERSION_UNCOMPRESSED);
int nSize = i2o_ECPublicKey(pKey, NULL);
std::vector<unsigned char> pubKey(nSize, 0)
unsigned char* pBegin = &pubKey[0];
i2o_ECPublicKey(pKey, &pBegin)
return pubKey;
}
But how can I get the uncompressed public key from the compressed public key without knowing the private key?