* @return a PKCS8 representation of the key.
*/
public byte[] getEncoded()
{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
DEROutputStream dOut = new DEROutputStream(bOut);
PrivateKeyInfo info = new PrivateKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.dhKeyAgreement, new DHParameter(dhSpec.getP(), dhSpec.getG(), dhSpec.getL()).getDERObject()), new DERInteger(getX()));
try
{
dOut.writeObject(info);
dOut.close();
}
catch (IOException e)
{
throw new RuntimeException("Error encoding DH private key");
}