Modular Exponentiation (PowMod)
Calculator and formula for computing modular exponentiation (PowMod)
Modular exponentiation calculator
What is calculated?
This function returns the result of the Modular Exponentiation (PowMod). The result is the remainder of a division of b^e by m, computed as (b^e) mod m.
Modular exponentiation info
Properties
Modular exponentiation:
- Computes (b^e) mod m efficiently
- Avoids large intermediate results
- Result always between 0 and m-1
- Important in cryptography
Note: Base b and modulo m must be positive integers. Exponent e can be 0.
Examples
9 mod 5 = 4
8 mod 7 = 1
625 mod 11 = 9
Any number to the power 0 is 1
Applications
- RSA encryption
- Diffie-Hellman key exchange
- Digital signatures
- Pseudorandom number generation
|
Formulas of modular exponentiation
Basic formula
Equivalent form
Multiplication rule
Power rule
Fermat's little theorem
Euler's theorem
Calculation example
Example: calculate 4² mod 10
Given:
- Base b = 4
- Exponent e = 2
- Modulo m = 10
Calculation:
Result: The remainder of 16 ÷ 10 is 6.
RSA encryption example
Simplified RSA example
RSA parameters:
- p = 3, q = 11 (primes)
- n = p·q = 33
- φ(n) = (p-1)·(q-1) = 20
- e = 3 (public exponent)
Encrypting m = 4:
Result: Message 4 is encrypted to 31.
Fast exponentiation
Example: 5¹³ mod 13 using binary method
Binary representation:
13 = 1101₂ = 8 + 4 + 1
5¹³ = 5⁸ · 5⁴ · 5¹
Stepwise calculation:
5² mod 13 = 12
5⁴ mod 13 = 1
5⁸ mod 13 = 1
5¹³ mod 13 = 1·1·5 = 5
Advantage: Only log₂(13) ≈ 4 multiplications instead of 12.
Definition and applications
What is modular exponentiation?
Modular exponentiation computes (b^e) mod m efficiently without explicitly calculating the often very large number b^e. This is essential for cryptographic applications that use large numbers.
Cryptographic significance
In modern cryptography modular exponentiation underpins: RSA encryption, Diffie-Hellman key exchange, digital signatures, and many other security schemes.
Algorithmic efficiency
- Naive method: O(e) multiplications
- Binary method: O(log e) multiplications
- Memory advantage: No large intermediate results
- Practical: Usable for very large exponents