Function light_poseidon::validate_bytes_length
source · pub fn validate_bytes_length<F>(input: &[u8]) -> Result<&[u8], PoseidonError>where
F: PrimeField,
Expand description
Checks whether a slice of bytes is not empty or its length does not exceed the modulus size od the prime field. If it does, an error is returned.
Safety
PrimeField::from_be_bytes_mod_order
just takes a subslice of the input if it’s too large, potentially leading
to collisions. The purpose of this function is to prevent them by returning
and error. It should be always used before converting byte slices to
prime field elements.