pub fn from_bytes(bytes: &[u8]) -> Result<Handshake, ()> {
        if bytes.len() != HANDSHAKE_LENGTH {
            return Err(());
        }
        let mut session_id: [u8; SESSION_ID_LENGTH] = [0u8; SESSION_ID_LENGTH];
        session_id.copy_from_slice(&bytes[..SESSION_ID_LENGTH]);

        let mut originator_id: [u8; ORIGINATOR_ID_LENGTH] = [0u8; ORIGINATOR_ID_LENGTH];
        originator_id
            .copy_from_slice(&bytes[SESSION_ID_LENGTH..SESSION_ID_LENGTH + ORIGINATOR_ID_LENGTH]);

        let mut application_instance_id: [u8; APPLICATION_INSTANCE_ID_LENGTH] =
            [0u8; APPLICATION_INSTANCE_ID_LENGTH];
        application_instance_id.copy_from_slice(
            &bytes[SESSION_ID_LENGTH + ORIGINATOR_ID_LENGTH
                ..SESSION_ID_LENGTH + ORIGINATOR_ID_LENGTH + APPLICATION_INSTANCE_ID_LENGTH],
        );

        let mut bits: [u8; BLINDED_POINT_LENGTH] = [0u8; BLINDED_POINT_LENGTH];
        bits.copy_from_slice(
            &bytes[SESSION_ID_LENGTH + ORIGINATOR_ID_LENGTH + APPLICATION_INSTANCE_ID_LENGTH..],
        );

        Ok(Handshake {
            session_id: session_id.iter().any(|x| *x != 0).then(|| session_id),
            originator_id,
            application_instance_id,
            blinded_password: CompressedRistretto(bits),
        })
    }
/// Construct a Handshake from a slice of bytes
Construct a Handshake from a slice of bytes
Construct a Handshake from a slice of bytes
pub fn from_bytes(bytes: &[u8]) -> Result<Handshake, ()> {
        if bytes.len() != HANDSHAKE_LENGTH {
            return Err(());
        }
        let mut session_id: [u8; SESSION_ID_LENGTH] = [0u8; SESSION_ID_LENGTH];
        session_id.copy_from_slice(&bytes[..SESSION_ID_LENGTH]);
        let mut originator_id: [u8; ORIGINATOR_ID_LENGTH] = [0u8; ORIGINATOR_ID_LENGTH];
        originator_id
            .copy_from_slice(&bytes[SESSION_ID_LENGTH..SESSION_ID_LENGTH + ORIGINATOR_ID_LENGTH]);
        let mut application_instance_id: [u8; APPLICATION_INSTANCE_ID_LENGTH] =
            [0u8; APPLICATION_INSTANCE_ID_LENGTH];
        application_instance_id.copy_from_slice(
            &bytes[SESSION_ID_LENGTH + ORIGINATOR_ID_LENGTH
                ..SESSION_ID_LENGTH + ORIGINATOR_ID_LENGTH + APPLICATION_INSTANCE_ID_LENGTH],
        );
        let mut bits: [u8; BLINDED_POINT_LENGTH] = [0u8; BLINDED_POINT_LENGTH];
        bits.copy_from_slice(
            &bytes[SESSION_ID_LENGTH + ORIGINATOR_ID_LENGTH + APPLICATION_INSTANCE_ID_LENGTH..],
        );
        Ok(Handshake {
            session_id: session_id.iter().any(|x| *x != 0).then(|| session_id),
            originator_id,
            application_instance_id,
            blinded_password: CompressedRistretto(bits),
        })
    }
pub fn from_bytes ( bytes : & [ u8 ] ) -> Result < Handshake , ( ) > { if bytes . len ( ) != HANDSHAKE_LENGTH { return Err ( ( ) ) ; } let mut session_id : [ u8 ; SESSION_ID_LENGTH ] = [ 0u8 ; SESSION_ID_LENGTH ] ; session_id . copy_from_slice ( & bytes [ .. SESSION_ID_LENGTH ] ) ; let mut originator_id : [ u8 ; ORIGINATOR_ID_LENGTH ] = [ 0u8 ; ORIGINATOR_ID_LENGTH ] ; originator_id . copy_from_slice ( & bytes [ SESSION_ID_LENGTH .. SESSION_ID_LENGTH + ORIGINATOR_ID_LENGTH ] ) ; let mut application_instance_id : [ u8 ; APPLICATION_INSTANCE_ID_LENGTH ] = [ 0u8 ; APPLICATION_INSTANCE_ID_LENGTH ] ; application_instance_id . copy_from_slice ( & bytes [ SESSION_ID_LENGTH + ORIGINATOR_ID_LENGTH .. SESSION_ID_LENGTH + ORIGINATOR_ID_LENGTH + APPLICATION_INSTANCE_ID_LENGTH ] , ) ; let mut bits : [ u8 ; BLINDED_POINT_LENGTH ] = [ 0u8 ; BLINDED_POINT_LENGTH ] ; bits . copy_from_slice ( & bytes [ SESSION_ID_LENGTH + ORIGINATOR_ID_LENGTH + APPLICATION_INSTANCE_ID_LENGTH .. ] , ) ; Ok ( Handshake { session_id : session_id . iter ( ) . any ( | x | * x != 0 ) . then ( | | session_id ) , originator_id , application_instance_id , blinded_password : CompressedRistretto ( bits ) , } ) }
Construct a Handshake from a slice of bytes
Construct a Handshake from a slice of bytes
bytes
&[u8]
bytes
&[u8]