powMod2k
Computes modular exponentiation modulo a power of 2: base^exp mod 2^k.
Uses optimized binary exponentiation with bit masking for efficiency.
Parameters
base | The base value |
exp | The exponent |
k | The power of 2 for the modulus (result is mod 2^k) |
Returns
base^exp mod 2^k