public static EcdsaPrivateKey generateEcdsaPrivKey(
      EllipticCurveType curve, HashType hashType, EcdsaSignatureEncoding encoding)
      throws Exception {
    ECParameterSpec ecParams;
    switch (curve) {
      case NIST_P256:
        ecParams = EllipticCurves.getNistP256Params();
        break;
      case NIST_P384:
        ecParams = EllipticCurves.getNistP384Params();
        break;
      case NIST_P521:
        ecParams = EllipticCurves.getNistP521Params();
        break;
      default:
        throw new NoSuchAlgorithmException("Curve not implemented:" + curve);
    }
    KeyPairGenerator keyGen = KeyPairGenerator.getInstance("EC");
    keyGen.initialize(ecParams);
    KeyPair keyPair = keyGen.generateKeyPair();
    ECPublicKey pubKey = (ECPublicKey) keyPair.getPublic();
    ECPrivateKey privKey = (ECPrivateKey) keyPair.getPrivate();
    ECPoint w = pubKey.getW();
    EcdsaPublicKey ecdsaPubKey =
        createEcdsaPubKey(
            hashType, curve, encoding, w.getAffineX().toByteArray(), w.getAffineY().toByteArray());

    return createEcdsaPrivKey(ecdsaPubKey, privKey.getS().toByteArray());
  }
@return a {@code EcdsaPrivateKey} constructed from {@code EllipticCurveType} and {@code
    HashType}.
java_src/src/main/java/com/google/crypto/tink/testing/TestUtil.java