According to Primality test Wikipedia page, Miller–Rabin primality test is described as;
The Miller–Rabin primality test works as follows: Given an integer n, choose some positive integer a < n. Let 2sd = n − 1, where d is odd. If
${a}^{d} \not \equiv 1 \pmod{n}$
and
$a^{2^{r}d}\not \equiv -1{\pmod {n}}$ for all $0\leq r\leq s-1$,
then n is composite and a is a witness for the compositeness. Otherwise, n may or may not be prime. The Miller–Rabin test is a strong pseudoprime test (see PSW[3] page 1004).
In applications like Cryptography, n is usually a very big number, 2048 bit number is not unusual. In the equation, 2sd = n − 1, when s is very small number like 1 or 2, d also have to be a very big number, it could have 2047 or 2046 significant bits.
In such cases, how is ${a}^{d} \not \equiv 1 \pmod{n}$ calculated, as resulting number has to be exponentially huge.