DHParameters dhParams = pGen.generateParameters();
DHKeyGenerationParameters params = new DHKeyGenerationParameters(new SecureRandom(), dhParams);
DHBasicKeyPairGenerator kpGen = new DHBasicKeyPairGenerator();
kpGen.init(params);
//
// generate first pair
//
AsymmetricCipherKeyPair pair = kpGen.generateKeyPair();
DHPublicKeyParameters pu1 = (DHPublicKeyParameters)pair.getPublic();
DHPrivateKeyParameters pv1 = (DHPrivateKeyParameters)pair.getPrivate();
//
// generate second pair
//
params = new DHKeyGenerationParameters(new SecureRandom(), pu1.getParameters());
kpGen.init(params);
pair = kpGen.generateKeyPair();
DHPublicKeyParameters pu2 = (DHPublicKeyParameters)pair.getPublic();
DHPrivateKeyParameters pv2 = (DHPrivateKeyParameters)pair.getPrivate();
//