title: Creating an elliptic curve point object from coordinates
body: <p>I have the x and y coordinate of a point and the name of a curve. I now want to create an <code>org.bouncycastle.jce.interfaces.ECPublicKey</code> object from that, automatically using the implementation that is provided. The goal is to be able to create the objects no matter if bouncycastle or its Android port, spongycastle, is used.</p>
  
  <p>This is what I'm doing right now. Thing is, the EC5Util class is not included in spongycastle. I'd like to have a solution using maybe a factory with just one method I have to call. Is that possible?</p>
  
  <pre><code>java.security.spec.ECPoint w = new java.security.spec.ECPoint(x, y);
  ECNamedCurveParameterSpec params = ECNamedCurveTable.getParameterSpec("secp256k1");
  KeyFactory fact = KeyFactory.getInstance("ECDSA", "BC");
  ECCurve curve = params.getCurve();
  java.security.spec.EllipticCurve ellipticCurve = EC5Util.convertCurve(curve, params.getSeed());
  java.security.spec.ECParameterSpec params2 = EC5Util.convertSpec(ellipticCurve, params);
  java.security.spec.ECPublicKeySpec keySpec = new java.security.spec.ECPublicKeySpec(w, params2);
  return (ECPublicKey) fact.generatePublic(keySpec);
  </code></pre>