crypto-bigint 0.7.2

Pure Rust implementation of a big integer library which has been designed from the ground-up for use in cryptographic applications. Provides constant-time, no_std-friendly implementations of modern formulas using const generics.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! [`BoxedUint`] modular exponentiation operations.

use crate::{
    BoxedUint, Odd,
    modular::{BoxedMontyForm, BoxedMontyParams},
};

impl BoxedUint {
    /// Computes `self ^ rhs mod p` for odd `p`.
    #[must_use]
    pub fn pow_mod(&self, rhs: &BoxedUint, p: &Odd<BoxedUint>) -> BoxedUint {
        BoxedMontyForm::new(self.clone(), &BoxedMontyParams::new(p.clone()))
            .pow(rhs)
            .retrieve()
    }
}

// NOTE: tested via proptests in `tests/boxed_uint.rs`