public void SetSessionKey(String pubKeyString, String scrambler = null) { BigInteger pubKey = BigIntegerExtension.Create(pubKeyString, 16); if (scrambler == null) // Server SessionKey { // (Av^u) ^ b (mod N) SessionKey = pubKey.multiply(verifier.modPow(Scrambler, Modulus)).modPow(PrivateKey, Modulus); } else // Client SessionKey { Scrambler = BigIntegerExtension.Create(scrambler, 16); BigInteger temp = PrivateKey.add(Scrambler.multiply(SaltedIdentityHash)); SessionKey = pubKey.subtract((Generator.modPow(SaltedIdentityHash, Modulus)).multiply(Multiplier)).modPow(temp, Modulus); } }