pub fn scalar_exp_vartime(x: &Scalar, mut n: u64) -> Scalar {
    let mut result = Scalar::one();
    let mut aux = *x; // x, x^2, x^4, x^8, ...
    while n > 0 {
        let bit = n & 1;
        if bit == 1 {
            result *= aux;
        }
        n >>= 1;
        aux = aux * aux; // FIXME: one unnecessary mult at the last step here!
    }
    result
}
/// Raises `x` to the power `n` using binary exponentiation,
/// with (1 to 2)*lg(n) scalar multiplications.
/// TODO: a consttime version of this would be awfully similar to a Montgomery ladder.
Raises `x` to the power `n` using binary exponentiation,
with (1 to 2)*lg(n) scalar multiplications.
TODO: a consttime version of this would be awfully similar to a Montgomery ladder.
Raises ` x ` to the power ` n ` using binary exponentiation with ( 1 to 2 ) * lg ( n ) scalar multiplications . TODO : a consttime version of this would be awfully similar to a Montgomery ladder .
pub fn scalar_exp_vartime(x: &Scalar, mut n: u64) -> Scalar {
    let mut result = Scalar::one();
    let mut aux = *x; // x, x^2, x^4, x^8, ...
    while n > 0 {
        let bit = n & 1;
        if bit == 1 {
            result *= aux;
        }
        n >>= 1;
        aux = aux * aux; // FIXME: one unnecessary mult at the last step here!
    }
    result
}
pub fn scalar_exp_vartime ( x : & Scalar , mut n : u64 ) -> Scalar { let mut result = Scalar :: one ( ) ; let mut aux = * x ; // x, x^2, x^4, x^8, ... while n > 0 { let bit = n & 1 ; if bit == 1 { result *= aux ; } n >>= 1 ; aux = aux * aux ; // FIXME: one unnecessary mult at the last step here! } result }
Raises `x` to the power `n` using binary exponentiation,
with (1 to 2)*lg(n) scalar multiplications.
Raises ` x ` to the power ` n ` using binary exponentiation with ( 1 to 2 ) * lg ( n ) scalar multiplications .
x
&Scalar
n
u64
x
&Scalar
n
u64