PrivateKey key)
throws InvalidKeyException
{
if (key instanceof ElGamalPrivateKey)
{
ElGamalPrivateKey k = (ElGamalPrivateKey)key;
return new ElGamalPrivateKeyParameters(k.getX(),
new ElGamalParameters(k.getParameters().getP(), k.getParameters().getG()));
}
else if (key instanceof DHPrivateKey)
{
DHPrivateKey k = (DHPrivateKey)key;
return new ElGamalPrivateKeyParameters(k.getX(),
new ElGamalParameters(k.getParams().getP(), k.getParams().getG()));
}
throw new InvalidKeyException("can't identify private key for El Gamal.");
}