I tried to calculate ECDH secret using my private EC key and a ephemeral peer key. The peer key is in raw compressed byte format (i.e 0x02 + 32 bytes). I manage to do it using bouncycastle library, thank to the "ECPoint org.bouncycastle.math.ec.ECCurve.decodePoint(byte[] arg0)" method. Unfortunately, I'm not able to find a way to perform the same operation using Java JCA. Bouncycastle is not an option because the final project will be in a Java Card.
// convert bouncycastle public key to Java public key
ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec("secp256k1");
ECPoint Q = publicKeyParams.getQ();
ECPublicKeySpec pubSpec = new ECPublicKeySpec(Q, ecSpec);
PublicKey javaPublicKey = keyFactory.generatePublic(pubSpec);
give "The constructor ECPublicKeySpec(ECPoint, ECPublicKeySpec) is undefined"