public static KeyPair recoverKeyPair(byte[] encoded) throws NoSuchAlgorithmException,
			InvalidKeySpecException {
		final String algo = getAlgorithmForOid(getOidFromPkcs8Encoded(encoded));

		final KeySpec privKeySpec = new PKCS8EncodedKeySpec(encoded);

		final KeyFactory kf = KeyFactory.getInstance(algo);
		final PrivateKey priv = kf.generatePrivate(privKeySpec);

		return new KeyPair(recoverPublicKey(kf, priv), priv);
	}
@Test
	public void recoverKeyPair_Ec() throws Exception {
		KeyPair kp = PubkeyUtils.recoverKeyPair(EC_KEY_PKCS8);

		ECPublicKey pubKey = (ECPublicKey) kp.getPublic();

		assertEquals(EC_KEY_pub_x, pubKey.getW().getAffineX());
		assertEquals(EC_KEY_pub_y, pubKey.getW().getAffineY());
	}