public byte[] getEncoded() {
try {
ByteArrayWriter baw = new ByteArrayWriter();
baw.writeString(getAlgorithmName());
baw.writeBigInteger(pubkey.getParams().getP());
baw.writeBigInteger(pubkey.getParams().getQ());
baw.writeBigInteger(pubkey.getParams().getG());
baw.writeBigInteger(pubkey.getY());
return baw.toByteArray();
} catch (IOException ioe) {