if (spec == null) {
throw new NoSuchAlgorithmException("Couldn't get EC parameter spec for curve " + crv);
}
ECPrivateKeySpec privateKeySpec = new ECPrivateKeySpec(d.decodeToBigInteger(), spec);
KeyFactory keyFactory = getECKeyFactory();
return (ECPrivateKey)keyFactory.generatePrivate(privateKeySpec);
}