DiffieHellman { public static BigInteger generateSecretKey(BigInteger remotePublicKey, BigInteger privateKey) { return remotePublicKey.modPow(privateKey, primeNumber); }  static BigInteger generateSecretKey(BigInteger remotePublicKey, BigInteger privateKey); static BigInteger generatePublicKey(BigInteger privateKey); static BigInteger generatePrivateKey(int bitLength);  }
@Test public void testGenerateSecretKey() { BigInteger clientPrivateKey = DiffieHellman.generatePrivateKey(160); BigInteger clientPublicKey = DiffieHellman.generatePublicKey(clientPrivateKey); BigInteger serverPrivateKey = DiffieHellman.generatePrivateKey(160); BigInteger serverPublicKey = DiffieHellman.generatePublicKey(serverPrivateKey); testDH(clientPrivateKey, clientPublicKey, serverPrivateKey, serverPublicKey); }