BigInteger p, g, x, y;
int qLength = param.getStrength() - 1;
ElGamalParameters elParams = param.getParameters();
p = elParams.getP();
g = elParams.getG();
//
// calculate the private key
//
x = new BigInteger(qLength, param.getRandom());
//
// calculate the public key.
//
y = g.modPow(x, p);
return new AsymmetricCipherKeyPair(
new ElGamalPublicKeyParameters(y, elParams),
new ElGamalPrivateKeyParameters(x, elParams));