pub fn from_bytes(mut b: [u8; 32]) -> CtOption<Self> {
        // Grab the sign bit from the representation
        let sign = b[31] >> 7;

        // Mask away the sign bit
        b[31] &= 0b0111_1111;

        // Interpret what remains as the v-coordinate
        Fq::from_bytes(&b).and_then(|v| {
            // -u^2 + v^2 = 1 + d.u^2.v^2
            // -u^2 = 1 + d.u^2.v^2 - v^2    (rearrange)
            // -u^2 - d.u^2.v^2 = 1 - v^2    (rearrange)
            // u^2 + d.u^2.v^2 = v^2 - 1     (flip signs)
            // u^2 (1 + d.v^2) = v^2 - 1     (factor)
            // u^2 = (v^2 - 1) / (1 + d.v^2) (isolate u^2)
            // We know that (1 + d.v^2) is nonzero for all v:
            //   (1 + d.v^2) = 0
            //   d.v^2 = -1
            //   v^2 = -(1 / d)   No solutions, as -(1 / d) is not a square

            let v2 = v.square();

            ((v2 - Fq::one()) * ((Fq::one() + EDWARDS_D * &v2).invert().unwrap_or(Fq::zero())))
                .sqrt()
                .and_then(|u| {
                    // Fix the sign of `u` if necessary
                    let flip_sign = Choice::from((u.to_bytes()[0] ^ sign) & 1);
                    let u_negated = -u;
                    let final_u = Fq::conditional_select(&u, &u_negated, flip_sign);

                    CtOption::new(AffinePoint { u: final_u, v }, Choice::from(1u8))
                })
        })
    }
/// Attempts to interpret a byte representation of an
/// affine point, failing if the element is not on
/// the curve or non-canonical.
Attempts to interpret a byte representation of an
affine point, failing if the element is not on
the curve or non-canonical.
Attempts to interpret a byte representation of an affine point failing if the element is not on the curve or non - canonical .
pub fn from_bytes(mut b: [u8; 32]) -> CtOption<Self> {
        // Grab the sign bit from the representation
        let sign = b[31] >> 7;
        // Mask away the sign bit
        b[31] &= 0b0111_1111;
        // Interpret what remains as the v-coordinate
        Fq::from_bytes(&b).and_then(|v| {
            // -u^2 + v^2 = 1 + d.u^2.v^2
            // -u^2 = 1 + d.u^2.v^2 - v^2    (rearrange)
            // -u^2 - d.u^2.v^2 = 1 - v^2    (rearrange)
            // u^2 + d.u^2.v^2 = v^2 - 1     (flip signs)
            // u^2 (1 + d.v^2) = v^2 - 1     (factor)
            // u^2 = (v^2 - 1) / (1 + d.v^2) (isolate u^2)
            // We know that (1 + d.v^2) is nonzero for all v:
            //   (1 + d.v^2) = 0
            //   d.v^2 = -1
            //   v^2 = -(1 / d)   No solutions, as -(1 / d) is not a square
            let v2 = v.square();
            ((v2 - Fq::one()) * ((Fq::one() + EDWARDS_D * &v2).invert().unwrap_or(Fq::zero())))
                .sqrt()
                .and_then(|u| {
                    // Fix the sign of `u` if necessary
                    let flip_sign = Choice::from((u.to_bytes()[0] ^ sign) & 1);
                    let u_negated = -u;
                    let final_u = Fq::conditional_select(&u, &u_negated, flip_sign);
                    CtOption::new(AffinePoint { u: final_u, v }, Choice::from(1u8))
                })
        })
    }
pub fn from_bytes ( mut b : [ u8 ; 32 ] ) -> CtOption < Self > { // Grab the sign bit from the representation let sign = b [ 31 ] >> 7 ; // Mask away the sign bit b [ 31 ] &= 0b0111_1111 ; // Interpret what remains as the v-coordinate Fq :: from_bytes ( & b ) . and_then ( | v | { // -u^2 + v^2 = 1 + d.u^2.v^2 // -u^2 = 1 + d.u^2.v^2 - v^2    (rearrange) // -u^2 - d.u^2.v^2 = 1 - v^2    (rearrange) // u^2 + d.u^2.v^2 = v^2 - 1     (flip signs) // u^2 (1 + d.v^2) = v^2 - 1     (factor) // u^2 = (v^2 - 1) / (1 + d.v^2) (isolate u^2) // We know that (1 + d.v^2) is nonzero for all v: //   (1 + d.v^2) = 0 //   d.v^2 = -1 //   v^2 = -(1 / d)   No solutions, as -(1 / d) is not a square let v2 = v . square ( ) ; ( ( v2 - Fq :: one ( ) ) * ( ( Fq :: one ( ) + EDWARDS_D * & v2 ) . invert ( ) . unwrap_or ( Fq :: zero ( ) ) ) ) . sqrt ( ) . and_then ( | u | { // Fix the sign of `u` if necessary let flip_sign = Choice :: from ( ( u . to_bytes ( ) [ 0 ] ^ sign ) & 1 ) ; let u_negated = - u ; let final_u = Fq :: conditional_select ( & u , & u_negated , flip_sign ) ; CtOption :: new ( AffinePoint { u : final_u , v } , Choice :: from ( 1u8 ) ) } ) } ) }
Attempts to interpret a byte representation of an
affine point, failing if the element is not on
the curve or non-canonical.
Attempts to interpret a byte representation of an affine point failing if the element is not on the curve or non - canonical .
b
[u8; 32]
b
[u8; 32]