private ECPoint getPublicKey() {
    final OpenSSLECPointContext pubKey =
        new OpenSSLECPointContext(
            group, new NativeRef.EC_POINT(NativeCrypto.EC_KEY_get_public_key(key.getNativeRef())));

    return pubKey.getECPoint();
  }
  private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
    stream.defaultReadObject();

    byte[] encoded = (byte[]) stream.readObject();

    key = new OpenSSLKey(NativeCrypto.d2i_PUBKEY(encoded));
    group =
        new OpenSSLECGroupContext(
            new NativeRef.EC_GROUP(NativeCrypto.EC_KEY_get1_group(key.getNativeRef())));
  }
 @Override
 public byte[] getEncoded() {
   return NativeCrypto.i2d_PUBKEY(key.getNativeRef());
 }
 public OpenSSLECPublicKey(OpenSSLKey key) {
   this.group =
       new OpenSSLECGroupContext(
           new NativeRef.EC_GROUP(NativeCrypto.EC_KEY_get1_group(key.getNativeRef())));
   this.key = key;
 }
 @Override
 public String toString() {
   return NativeCrypto.EVP_PKEY_print_public(key.getNativeRef());
 }
 @Override
 public int hashCode() {
   return Arrays.hashCode(NativeCrypto.i2d_PUBKEY(key.getNativeRef()));
 }