pow_mod

Function pow_mod 

Source
pub fn pow_mod(base: &BigUint, exp: &BigUint, modulus: &BigUint) -> BigUint
Expand description

Computes the modular exponentiation of a BigUint base raised to a BigUint exponent modulo another BigUint.

This function calculates (base ^ exp) % modulus using an efficient binary exponentiation algorithm, which is useful for large numbers in cryptographic applications.

§Arguments

  • base - A reference to a BigUint representing the base.
  • exp - A reference to a BigUint representing the exponent.
  • modulus - A reference to a BigUint representing the modulus.

§Returns

The result of (base ^ exp) % modulus.

§Examples

use num_bigint::BigUint;
use large_primes::pow_mod;
 
let base = BigUint::from(4u32);
let exponent = BigUint::from(13u32);
let modulus = BigUint::from(497u32);
let result = pow_mod(&base, &exponent, &modulus);
assert_eq!(result, BigUint::from(445u32));