Skip to main content

crypto_bigint/uint/boxed/
pow_mod.rs

1//! [`BoxedUint`] modular exponentiation operations.
2
3use crate::{
4    BoxedUint, Odd,
5    modular::{BoxedMontyForm, BoxedMontyParams},
6};
7
8impl BoxedUint {
9    /// Computes `self ^ rhs mod p` for odd `p`.
10    #[must_use]
11    pub fn pow_mod(&self, rhs: &BoxedUint, p: &Odd<BoxedUint>) -> BoxedUint {
12        BoxedMontyForm::new(self.clone(), &BoxedMontyParams::new(p.clone()))
13            .pow(rhs)
14            .retrieve()
15    }
16}
17
18// NOTE: tested via proptests in `tests/boxed_uint.rs`