pub fn two_scalar_mul(
    base: &crate::EdwardsAffine,
    scalar_1: &Fr,
    endor_base: &crate::EdwardsAffine,
    scalar_2: &Fr,
    scalar_2_is_positive: bool,
) -> crate::EdwardsProjective {
    let b1 = (*base).into_projective();
    let s1 = *scalar_1;
    let mut b2 = (*endor_base).into_projective();
    let s2 = *scalar_2;

    if scalar_2_is_positive {
        b2 = -b2;
    }
    let s1: BigInteger256 = s1.into();
    let s2: BigInteger256 = s2.into();

    let b1b2 = b1 + b2;

    let s1_bits = s1.to_bits_le();
    let s2_bits = s2.to_bits_le();
    let s1_len = get_bits(&s1_bits);
    let s2_len = get_bits(&s2_bits);

    let len = max(s1_len, s2_len) as usize;

    let mut res = crate::EdwardsProjective::zero();
    for i in 0..len {
        res = res.double();
        if s1_bits[len - i - 1] && !s2_bits[len - i - 1] {
            res += b1
        }
        if !s1_bits[len - i - 1] && s2_bits[len - i - 1] {
            res += b2
        }
        if s1_bits[len - i - 1] && s2_bits[len - i - 1] {
            res += b1b2
        }
    }
    res
}
// Here we need to implement a customized MSM algorithm, since we know that
// the high bits of Fr are restricted to be small, i.e. ~ 128 bits.
// This MSM will save us some 128 doublings.
Here we need to implement a customized MSM algorithm, since we know that
the high bits of Fr are restricted to be small, i.e.
Here we need to implement a customized MSM algorithm since we know that the high bits of Fr are restricted to be small i . e .
pub fn two_scalar_mul(
    base: &crate::EdwardsAffine,
    scalar_1: &Fr,
    endor_base: &crate::EdwardsAffine,
    scalar_2: &Fr,
    scalar_2_is_positive: bool,
) -> crate::EdwardsProjective {
    let b1 = (*base).into_projective();
    let s1 = *scalar_1;
    let mut b2 = (*endor_base).into_projective();
    let s2 = *scalar_2;
    if scalar_2_is_positive {
        b2 = -b2;
    }
    let s1: BigInteger256 = s1.into();
    let s2: BigInteger256 = s2.into();
    let b1b2 = b1 + b2;
    let s1_bits = s1.to_bits_le();
    let s2_bits = s2.to_bits_le();
    let s1_len = get_bits(&s1_bits);
    let s2_len = get_bits(&s2_bits);
    let len = max(s1_len, s2_len) as usize;
    let mut res = crate::EdwardsProjective::zero();
    for i in 0..len {
        res = res.double();
        if s1_bits[len - i - 1] && !s2_bits[len - i - 1] {
            res += b1
        }
        if !s1_bits[len - i - 1] && s2_bits[len - i - 1] {
            res += b2
        }
        if s1_bits[len - i - 1] && s2_bits[len - i - 1] {
            res += b1b2
        }
    }
    res
}
pub fn two_scalar_mul ( base : & crate :: EdwardsAffine , scalar_1 : & Fr , endor_base : & crate :: EdwardsAffine , scalar_2 : & Fr , scalar_2_is_positive : bool , ) -> crate :: EdwardsProjective { let b1 = ( * base ) . into_projective ( ) ; let s1 = * scalar_1 ; let mut b2 = ( * endor_base ) . into_projective ( ) ; let s2 = * scalar_2 ; if scalar_2_is_positive { b2 = - b2 ; } let s1 : BigInteger256 = s1 . into ( ) ; let s2 : BigInteger256 = s2 . into ( ) ; let b1b2 = b1 + b2 ; let s1_bits = s1 . to_bits_le ( ) ; let s2_bits = s2 . to_bits_le ( ) ; let s1_len = get_bits ( & s1_bits ) ; let s2_len = get_bits ( & s2_bits ) ; let len = max ( s1_len , s2_len ) as usize ; let mut res = crate :: EdwardsProjective :: zero ( ) ; for i in 0 .. len { res = res . double ( ) ; if s1_bits [ len - i - 1 ] && ! s2_bits [ len - i - 1 ] { res += b1 } if ! s1_bits [ len - i - 1 ] && s2_bits [ len - i - 1 ] { res += b2 } if s1_bits [ len - i - 1 ] && s2_bits [ len - i - 1 ] { res += b1b2 } } res }
Here we need to implement a customized MSM algorithm, since we know that
the high bits of Fr are restricted to be small, i.e.
Here we need to implement a customized MSM algorithm since we know that the high bits of Fr are restricted to be small i . e .
base
&crate::EdwardsAffine
scalar_1
&Fr
endor_base
&crate::EdwardsAffine
scalar_2
&Fr
scalar_2_is_positive
bool
base
&crate::EdwardsAffine
scalar_1
&Fr
endor_base
&crate::EdwardsAffine
scalar_2
&Fr
scalar_2_is_positive
bool