pub fn bytes_to_field<I, F>(bytes: I) -> impl Iterator<Item = F>
Expand description
Deterministic, infallible, invertible iterator adaptor to convert from arbitrary bytes to field elements.
The final field element is padded with zero bytes as needed.
§Example
[doctest ignored because it’s a private module.]
ⓘ
let bytes = [1, 2, 3];
let mut elems_iter = bytes_to_field::<_, Fr254>(bytes);
assert_eq!(elems_iter.next(), Some(Fr254::from(197121u64)));
assert_eq!(elems_iter.next(), None);
§Panics
Panics only under conditions that should be checkable at compile time:
- The [
PrimeField
] modulus bit length is too small to hold au64
. - The [
PrimeField
] byte length is too large to fit inside ausize
.
If any of the above conditions holds then this function always panics.