{
DHParameters dhParams = new DHParameters(p, g);
DHKeyGenerationParameters params = new DHKeyGenerationParameters(new SecureRandom(), dhParams);
DHKeyPairGenerator kpGen = new DHKeyPairGenerator();
kpGen.init(params);
//
// generate first pair
//
AsymmetricCipherKeyPair pair = kpGen.generateKeyPair();
DHPublicKeyParameters pu1 = (DHPublicKeyParameters)pair.getPublic();
DHPrivateKeyParameters pv1 = (DHPrivateKeyParameters)pair.getPrivate();
//
// generate second pair
//
pair = kpGen.generateKeyPair();
DHPublicKeyParameters pu2 = (DHPublicKeyParameters)pair.getPublic();
DHPrivateKeyParameters pv2 = (DHPrivateKeyParameters)pair.getPrivate();
//