BigInteger p, g, x, y;
int qLength = param.getStrength() - 1;
DHParameters dhParams = param.getParameters();
p = dhParams.getP();
g = dhParams.getG();
//
// calculate the private key
//
x = new BigInteger(qLength, param.getRandom());
//
// calculate the public key.
//
y = g.modPow(x, p);
return new AsymmetricCipherKeyPair(
new DHPublicKeyParameters(y, dhParams),
new DHPrivateKeyParameters(x, dhParams));