pub fn fr_from_bytes(bytes: &[u8; FR_SIZE]) -> Result<Scalar, ScalarDecodingError> {
    let mut le_bytes = [0u8; 32];

    for i in 0..FR_SIZE {
        le_bytes[i] = bytes[FR_SIZE - i - 1];
    }
    let s = Scalar::from_bytes(&le_bytes);

    if bool::from(s.is_none()) {
        return Err(ScalarDecodingError::InvalidScalar);
    }

    Ok(s.unwrap())
}
/// Decode BLS12-381 field element from bytes
///
/// # Arguments
/// * `bytes`: encoding of a field element
/// # Errors
/// * `ScalarDecodingError` if the input is invalid (out of range)
/// # Returns
/// The decoded field element
Decode BLS12-381 field element from bytes
Decode BLS12 - 381 field element from bytes
pub fn fr_from_bytes(bytes: &[u8; FR_SIZE]) -> Result<Scalar, ScalarDecodingError> {
    let mut le_bytes = [0u8; 32];
    for i in 0..FR_SIZE {
        le_bytes[i] = bytes[FR_SIZE - i - 1];
    }
    let s = Scalar::from_bytes(&le_bytes);
    if bool::from(s.is_none()) {
        return Err(ScalarDecodingError::InvalidScalar);
    }
    Ok(s.unwrap())
}
pub fn fr_from_bytes ( bytes : & [ u8 ; FR_SIZE ] ) -> Result < Scalar , ScalarDecodingError > { let mut le_bytes = [ 0u8 ; 32 ] ; for i in 0 .. FR_SIZE { le_bytes [ i ] = bytes [ FR_SIZE - i - 1 ] ; } let s = Scalar :: from_bytes ( & le_bytes ) ; if bool :: from ( s . is_none ( ) ) { return Err ( ScalarDecodingError :: InvalidScalar ) ; } Ok ( s . unwrap ( ) ) }
Decode BLS12-381 field element from bytes
Decode BLS12 - 381 field element from bytes
bytes
&[u8; FR_SIZE]
The decoded field element
The decoded field element
bytes
&[u8; FR_SIZE]
errors
`ScalarDecodingError` if the input is invalid (out of range)
` ScalarDecodingError ` if the input is invalid ( out of range )