Skip to main content

crypto_bigint/limb/
invert_mod.rs

1use super::Limb;
2use crate::{Odd, primitives};
3
4impl Odd<Limb> {
5    /// Returns the multiplicative inverse of the argument modulo 2^N, where
6    /// 2^N is the capacity of a [`Limb`].
7    pub(crate) const fn multiplicative_inverse(self) -> Limb {
8        cpubits::cpubits! {
9            32 => {
10                Limb(primitives::u32_invert_odd(self.as_ref().0))
11            }
12            64 => {
13                Limb(primitives::u64_invert_odd(self.as_ref().0))
14            }
15        }
16    }
17}