pathfinder-crypto 0.22.5

Cryptographic primitives used by Pathfinder
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use crate::algebra::field::bits::BitIteratorBE;
use crate::MontFelt;

impl MontFelt {
    /// Computes `self^exp` where `exp` is u64 limbs in little-endian.
    pub(crate) fn pow<S: AsRef<[u64]>>(&self, exp: S) -> Self {
        let mut res = Self::ONE;
        for i in BitIteratorBE::without_leading_zeros(exp) {
            res = res.square();
            if i {
                res *= self;
            }
        }
        res
    }
}