checkIsBigInteger(val, "Wrong Q field");
DerUtil.checkIsBigInteger(val, "Wrong Q field");
  public PublicKey decodePublicKey(byte[] input)  {    if (input == null)      throw new InvalidParameterException("Input bytes MUST NOT be null");    BigInteger p, g, q, y;    DERReader der = new DERReader(input);    try      {        DERValue derSPKI = der.read();        checkIsConstructed(derSPKI, "Wrong SubjectPublicKeyInfo field");        DERValue derAlgorithmID = der.read();        checkIsConstructed(derAlgorithmID, "Wrong AlgorithmIdentifier field");        DERValue derOID = der.read();        if (! (derOID.getValue() instanceof OID))          throw new InvalidParameterException("Wrong Algorithm field");        OID algOID = (OID) derOID.getValue();        if (! algOID.equals(DH_ALG_OID))          throw new InvalidParameterException("Unexpected OID: " + algOID);        DERValue derParams = der.read();        checkIsConstructed(derParams, "Wrong DH Parameters field");        DERValue val = der.read();        checkIsBigInteger(val, "Wrong P field");        p = (BigInteger) val.getValue();        val = der.read();        checkIsBigInteger(val, "Wrong G field");        g = (BigInteger) val.getValue();        val = der.read();        checkIsBigInteger(val, "Wrong Q field");        q = (BigInteger) val.getValue();        val = der.read();        if (! (val.getValue() instanceof BitString))          throw new InvalidParameterException("Wrong SubjectPublicKey field");        byte[] yBytes = ((BitString) val.getValue()).toByteArray();        DERReader dhPub = new DERReader(yBytes);        val = dhPub.read();        checkIsBigInteger(val, "Wrong Y field");        y = (BigInteger) val.getValue();      }    catch (IOException x)      {        InvalidParameterException e = new InvalidParameterException();        e.initCause(x);        throw e;      }    return new GnuDHPublicKey(Registry.X509_ENCODING_ID, q, p, g, y);  }