How can I get the uncompressed public key from the compressed public key in openssl? 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&lt;unsigned char&gt; 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&lt;unsigned char&gt; pubKey(nSize, 0)
    unsigned char* pBegin = &amp;pubKey[0];
    i2o_ECPublicKey(pKey, &amp;pBegin)
    return pubKey;
}


But how can I get the uncompressed public key from the compressed public key without knowing the private key?
If you have a compressed octet pubkey, use octet to point, then point to octet.

EC_POINT_oct2point(group, point, data, size, ctx);
EC_POINT_point2oct(group, point, POINT_CONVERSION_UNCOMPRESSED, data, len, ctx);