 <p><code>X509EncodedKeySpec(key)</code> or <code>PKCS8EncodedKeySpec(key)</code> constructors take private/public keys in encoded format. Unencoded key bytes can be converted this way:</p> <pre><code>Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); ECNamedCurveParameterSpec spec = ECNamedCurveTable.getParameterSpec("secp192r1"); ECPrivateKeySpec ecPrivateKeySpec = new ECPrivateKeySpec(new BigInteger(1, privateKeyBytes), spec); ECNamedCurveSpec params = new ECNamedCurveSpec("secp192r1", spec.getCurve(), spec.getG(), spec.getN()); java.security.spec.ECPoint w = new java.security.spec.ECPoint(new BigInteger(1, Arrays.copyOfRange(publicKeyBytes, 0, 24)), new BigInteger(1, Arrays.copyOfRange(publicKeyBytes, 24, 48))); PublicKey publicKey = factory.generatePublic(new java.security.spec.ECPublicKeySpec(w, params)); </code></pre>