pub fn from_compressed_unchecked(bytes: &[u8; 96]) -> CtOption<Self> {
        // Obtain the three flags from the start of the byte sequence
        let compression_flag_set = Choice::from((bytes[0] >> 7) & 1);
        let infinity_flag_set = Choice::from((bytes[0] >> 6) & 1);
        let sort_flag_set = Choice::from((bytes[0] >> 5) & 1);

        // Attempt to obtain the x-coordinate
        let xc1 = {
            let mut tmp = [0; 48];
            tmp.copy_from_slice(&bytes[0..48]);

            // Mask away the flag bits
            tmp[0] &= 0b0001_1111;

            Fp::from_bytes(&tmp)
        };
        let xc0 = {
            let mut tmp = [0; 48];
            tmp.copy_from_slice(&bytes[48..96]);

            Fp::from_bytes(&tmp)
        };

        xc1.and_then(|xc1| {
            xc0.and_then(|xc0| {
                let x = Fp2 { c0: xc0, c1: xc1 };

                // If the infinity flag is set, return the value assuming
                // the x-coordinate is zero and the sort bit is not set.
                //
                // Otherwise, return a recovered point (assuming the correct
                // y-coordinate can be found) so long as the infinity flag
                // was not set.
                CtOption::new(
                    G2Affine::identity(),
                    infinity_flag_set & // Infinity flag should be set
                    compression_flag_set & // Compression flag should be set
                    (!sort_flag_set) & // Sort flag should not be set
                    x.is_zero(), // The x-coordinate should be zero
                )
                .or_else(|| {
                    // Recover a y-coordinate given x by y = sqrt(x^3 + 4)
                    ((x.square() * x) + B).sqrt().and_then(|y| {
                        // Switch to the correct y-coordinate if necessary.
                        let y = Fp2::conditional_select(
                            &y,
                            &-y,
                            y.lexicographically_largest() ^ sort_flag_set,
                        );

                        CtOption::new(
                            G2Affine {
                                x,
                                y,
                                infinity: infinity_flag_set,
                            },
                            (!infinity_flag_set) & // Infinity flag should not be set
                            compression_flag_set, // Compression flag should be set
                        )
                    })
                })
            })
        })
    }
/// Attempts to deserialize an uncompressed element, not checking if the
/// element is in the correct subgroup.
/// **This is dangerous to call unless you trust the bytes you are reading; otherwise,
/// API invariants may be broken.** Please consider using `from_compressed()` instead.
Attempts to deserialize an uncompressed element, not checking if the
element is in the correct subgroup.
This is dangerous to call unless you trust the bytes you are reading; otherwise,
API invariants may be broken.** Please consider using `from_compressed()` instead.
Attempts to deserialize an uncompressed element not checking if the element is in the correct subgroup . This is dangerous to call unless you trust the bytes you are reading ; otherwise API invariants may be broken . ** Please consider using ` from_compressed () ` instead .
pub fn from_compressed_unchecked(bytes: &[u8; 96]) -> CtOption<Self> {
        // Obtain the three flags from the start of the byte sequence
        let compression_flag_set = Choice::from((bytes[0] >> 7) & 1);
        let infinity_flag_set = Choice::from((bytes[0] >> 6) & 1);
        let sort_flag_set = Choice::from((bytes[0] >> 5) & 1);
        // Attempt to obtain the x-coordinate
        let xc1 = {
            let mut tmp = [0; 48];
            tmp.copy_from_slice(&bytes[0..48]);
            // Mask away the flag bits
            tmp[0] &= 0b0001_1111;
            Fp::from_bytes(&tmp)
        };
        let xc0 = {
            let mut tmp = [0; 48];
            tmp.copy_from_slice(&bytes[48..96]);
            Fp::from_bytes(&tmp)
        };
        xc1.and_then(|xc1| {
            xc0.and_then(|xc0| {
                let x = Fp2 { c0: xc0, c1: xc1 };
                // If the infinity flag is set, return the value assuming
                // the x-coordinate is zero and the sort bit is not set.
                //
                // Otherwise, return a recovered point (assuming the correct
                // y-coordinate can be found) so long as the infinity flag
                // was not set.
                CtOption::new(
                    G2Affine::identity(),
                    infinity_flag_set & // Infinity flag should be set
                    compression_flag_set & // Compression flag should be set
                    (!sort_flag_set) & // Sort flag should not be set
                    x.is_zero(), // The x-coordinate should be zero
                )
                .or_else(|| {
                    // Recover a y-coordinate given x by y = sqrt(x^3 + 4)
                    ((x.square() * x) + B).sqrt().and_then(|y| {
                        // Switch to the correct y-coordinate if necessary.
                        let y = Fp2::conditional_select(
                            &y,
                            &-y,
                            y.lexicographically_largest() ^ sort_flag_set,
                        );
                        CtOption::new(
                            G2Affine {
                                x,
                                y,
                                infinity: infinity_flag_set,
                            },
                            (!infinity_flag_set) & // Infinity flag should not be set
                            compression_flag_set, // Compression flag should be set
                        )
                    })
                })
            })
        })
    }
pub fn from_compressed_unchecked ( bytes : & [ u8 ; 96 ] ) -> CtOption < Self > { // Obtain the three flags from the start of the byte sequence let compression_flag_set = Choice :: from ( ( bytes [ 0 ] >> 7 ) & 1 ) ; let infinity_flag_set = Choice :: from ( ( bytes [ 0 ] >> 6 ) & 1 ) ; let sort_flag_set = Choice :: from ( ( bytes [ 0 ] >> 5 ) & 1 ) ; // Attempt to obtain the x-coordinate let xc1 = { let mut tmp = [ 0 ; 48 ] ; tmp . copy_from_slice ( & bytes [ 0 .. 48 ] ) ; // Mask away the flag bits tmp [ 0 ] &= 0b0001_1111 ; Fp :: from_bytes ( & tmp ) } ; let xc0 = { let mut tmp = [ 0 ; 48 ] ; tmp . copy_from_slice ( & bytes [ 48 .. 96 ] ) ; Fp :: from_bytes ( & tmp ) } ; xc1 . and_then ( | xc1 | { xc0 . and_then ( | xc0 | { let x = Fp2 { c0 : xc0 , c1 : xc1 } ; // If the infinity flag is set, return the value assuming // the x-coordinate is zero and the sort bit is not set. // // Otherwise, return a recovered point (assuming the correct // y-coordinate can be found) so long as the infinity flag // was not set. CtOption :: new ( G2Affine :: identity ( ) , infinity_flag_set & // Infinity flag should be set compression_flag_set & // Compression flag should be set ( ! sort_flag_set ) & // Sort flag should not be set x . is_zero ( ) , // The x-coordinate should be zero ) . or_else ( | | { // Recover a y-coordinate given x by y = sqrt(x^3 + 4) ( ( x . square ( ) * x ) + B ) . sqrt ( ) . and_then ( | y | { // Switch to the correct y-coordinate if necessary. let y = Fp2 :: conditional_select ( & y , & - y , y . lexicographically_largest ( ) ^ sort_flag_set , ) ; CtOption :: new ( G2Affine { x , y , infinity : infinity_flag_set , } , ( ! infinity_flag_set ) & // Infinity flag should not be set compression_flag_set , // Compression flag should be set ) } ) } ) } ) } ) }
Attempts to deserialize an uncompressed element, not checking if the
element is in the correct subgroup.
Attempts to deserialize an uncompressed element not checking if the element is in the correct subgroup .
bytes
&[u8; 96]
bytes
&[u8; 96]