Calculating K
To calculate our live session token, we need to use modulus division to receive a K value for a HMAC hash.
Begin by pulling the base value, B, which will be our dh_response value from our /live_session_token response, using a leading 0 as a sign bit for the hex string.
We will then need to retrieve a BigInteger value of the dh_response value.
Our exponent value would be equivalent to the same dh_random value used for our /live_session_token request.
Our modulus, p, would be the same as our dh_modulus or dh_prime value from our Diffie-Hellman file.
We would finally calculate K using the formula B^a modulo p.
Python
C#
Once K is receive, convert the integer to its hex string representation before converting it to a byte array. In some cases, the resultant K value will have an odd number of leading characters that should be prepended by an additional 0.

