Code example for BigInteger

Methods: modPow

0
        if (!pub.getParameters().equals(dhParams))
        { 
            throw new IllegalArgumentException("Diffie-Hellman public key has wrong parameters.");
        } 
 
        return message.modPow(key.getX(), dhParams.getP()).multiply(pub.getY().modPow(privateValue, dhParams.getP())).mod(dhParams.getP());
    } 
}