Here you can find the source of calculateGx(BigInteger p, BigInteger g, BigInteger x)
public static BigInteger calculateGx(BigInteger p, BigInteger g, BigInteger x)
//package com.java2s; import java.math.BigInteger; public class Main { /**/* w w w . j a va 2 s.c o m*/ * Calculate g^x mod p as done in round 1. */ public static BigInteger calculateGx(BigInteger p, BigInteger g, BigInteger x) { return g.modPow(x, p); } }