DERValue derParams = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, params);
derParams = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, params); }
  public byte[] encodePublicKey(PublicKey key)  {    if (! (key instanceof DSSPublicKey))      throw new InvalidParameterException("key");    DERValue derOID = new DERValue(DER.OBJECT_IDENTIFIER, DSA_ALG_OID);    DSSPublicKey dssKey = (DSSPublicKey) key;    BigInteger p = dssKey.getParams().getP();    BigInteger q = dssKey.getParams().getQ();    BigInteger g = dssKey.getParams().getG();    BigInteger y = dssKey.getY();    DERValue derP = new DERValue(DER.INTEGER, p);    DERValue derQ = new DERValue(DER.INTEGER, q);    DERValue derG = new DERValue(DER.INTEGER, g);    ArrayList params = new ArrayList(3);    params.add(derP);    params.add(derQ);    params.add(derG);    DERValue derParams = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, params);    ArrayList algorithmID = new ArrayList(2);    algorithmID.add(derOID);    algorithmID.add(derParams);    DERValue derAlgorithmID = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE,                                           algorithmID);    DERValue derDSAPublicKey = new DERValue(DER.INTEGER, y);    byte[] yBytes = derDSAPublicKey.getEncoded();    DERValue derSPK = new DERValue(DER.BIT_STRING, new BitString(yBytes));    ArrayList spki = new ArrayList(2);    spki.add(derAlgorithmID);    spki.add(derSPK);    DERValue derSPKI = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, spki);    byte[] result;    ByteArrayOutputStream baos = new ByteArrayOutputStream();    try      {        DERWriter.write(baos, derSPKI);        result = baos.toByteArray();      }    catch (IOException x)      {        InvalidParameterException e = new InvalidParameterException();        e.initCause(x);        throw e;      }    return result;  }