PublicKey key)
throws InvalidKeyException
{
if (key instanceof ElGamalPublicKey)
{
ElGamalPublicKey k = (ElGamalPublicKey)key;
return new ElGamalPublicKeyParameters(k.getY(),
new ElGamalParameters(k.getParameters().getP(), k.getParameters().getG()));
}
else if (key instanceof DHPublicKey)
{
DHPublicKey k = (DHPublicKey)key;
return new ElGamalPublicKeyParameters(k.getY(),
new ElGamalParameters(k.getParams().getP(), k.getParams().getG()));
}
throw new InvalidKeyException("can't identify public key for El Gamal.");
}