pub fn to_montgomery_coords(
    g: jubjub::ExtendedPoint,
) -> Option<(bls12_381::Scalar, bls12_381::Scalar)> {
    let g = g.to_affine();
    let (x, y) = (g.get_u(), g.get_v());

    if y == bls12_381::Scalar::one() {
        // The only solution for y = 1 is x = 0. (0, 1) is the neutral element, so we map
        // this to the point at infinity.
        None
    } else {
        // The map from a twisted Edwards curve is defined as
        // (x, y) -> (u, v) where
        //      u = (1 + y) / (1 - y)
        //      v = u / x
        //
        // This mapping is not defined for y = 1 and for x = 0.
        //
        // We have that y != 1 above. If x = 0, the only
        // solutions for y are 1 (contradiction) or -1.
        if x.is_zero() {
            // (0, -1) is the point of order two which is not
            // the neutral element, so we map it to (0, 0) which is
            // the only affine point of order 2.
            Some((bls12_381::Scalar::zero(), bls12_381::Scalar::zero()))
        } else {
            // The mapping is defined as above.
            //
            // (x, y) -> (u, v) where
            //      u = (1 + y) / (1 - y)
            //      v = u / x

            let u =
                (bls12_381::Scalar::one() + y) * (bls12_381::Scalar::one() - y).invert().unwrap();
            let v = u * x.invert().unwrap();

            // Scale it into the correct curve constants
            // scaling factor = sqrt(4 / (a - d))
            Some((u, v * MONTGOMERY_SCALE))
        }
    }
}
/// Returns the coordinates of this point's Montgomery curve representation, or `None` if
/// it is the point at infinity.
Returns the coordinates of this point's Montgomery curve representation, or `None` if
it is the point at infinity.
Returns the coordinates of this point ' s Montgomery curve representation or ` None ` if it is the point at infinity .
pub fn to_montgomery_coords(
    g: jubjub::ExtendedPoint,
) -> Option<(bls12_381::Scalar, bls12_381::Scalar)> {
    let g = g.to_affine();
    let (x, y) = (g.get_u(), g.get_v());
    if y == bls12_381::Scalar::one() {
        // The only solution for y = 1 is x = 0. (0, 1) is the neutral element, so we map
        // this to the point at infinity.
        None
    } else {
        // The map from a twisted Edwards curve is defined as
        // (x, y) -> (u, v) where
        //      u = (1 + y) / (1 - y)
        //      v = u / x
        //
        // This mapping is not defined for y = 1 and for x = 0.
        //
        // We have that y != 1 above. If x = 0, the only
        // solutions for y are 1 (contradiction) or -1.
        if x.is_zero() {
            // (0, -1) is the point of order two which is not
            // the neutral element, so we map it to (0, 0) which is
            // the only affine point of order 2.
            Some((bls12_381::Scalar::zero(), bls12_381::Scalar::zero()))
        } else {
            // The mapping is defined as above.
            //
            // (x, y) -> (u, v) where
            //      u = (1 + y) / (1 - y)
            //      v = u / x
            let u =
                (bls12_381::Scalar::one() + y) * (bls12_381::Scalar::one() - y).invert().unwrap();
            let v = u * x.invert().unwrap();
            // Scale it into the correct curve constants
            // scaling factor = sqrt(4 / (a - d))
            Some((u, v * MONTGOMERY_SCALE))
        }
    }
}
pub fn to_montgomery_coords ( g : jubjub :: ExtendedPoint , ) -> Option < ( bls12_381 :: Scalar , bls12_381 :: Scalar ) > { let g = g . to_affine ( ) ; let ( x , y ) = ( g . get_u ( ) , g . get_v ( ) ) ; if y == bls12_381 :: Scalar :: one ( ) { // The only solution for y = 1 is x = 0. (0, 1) is the neutral element, so we map // this to the point at infinity. None } else { // The map from a twisted Edwards curve is defined as // (x, y) -> (u, v) where //      u = (1 + y) / (1 - y) //      v = u / x // // This mapping is not defined for y = 1 and for x = 0. // // We have that y != 1 above. If x = 0, the only // solutions for y are 1 (contradiction) or -1. if x . is_zero ( ) { // (0, -1) is the point of order two which is not // the neutral element, so we map it to (0, 0) which is // the only affine point of order 2. Some ( ( bls12_381 :: Scalar :: zero ( ) , bls12_381 :: Scalar :: zero ( ) ) ) } else { // The mapping is defined as above. // // (x, y) -> (u, v) where //      u = (1 + y) / (1 - y) //      v = u / x let u = ( bls12_381 :: Scalar :: one ( ) + y ) * ( bls12_381 :: Scalar :: one ( ) - y ) . invert ( ) . unwrap ( ) ; let v = u * x . invert ( ) . unwrap ( ) ; // Scale it into the correct curve constants // scaling factor = sqrt(4 / (a - d)) Some ( ( u , v * MONTGOMERY_SCALE ) ) } } }
Returns the coordinates of this point's Montgomery curve representation, or `None` if
it is the point at infinity.
Returns the coordinates of this point ' s Montgomery curve representation or ` None ` if it is the point at infinity .
g
jubjub::ExtendedPoint
g
jubjub::ExtendedPoint