aztec-nr - noir_aztec::utils::conversion::fields_to_bytes

Function fields_from_bytes

pub fn fields_from_bytes<let N: u32>(bytes: BoundedVec<u8, N>) -> BoundedVec<Field, N / 32>

Converts an input BoundedVec of bytes into a BoundedVec of fields. Arbitrary byte arrays are not allowed: this is assumed to be an array obtained via fields_to_bytes, i.e. one that actually represents fields. To convert a byte array into Fields, use bytes_to_fields.

The input bytes are chunked into chunks of 32 bytes. Each 32-byte chunk is viewed as big-endian, and is converted into a Field. For example, [1, 10, 3, ..., 0] (32 bytes) is encoded as [1 * 256^31 + 10 * 256^30 + 3 * 256^29 + ... + 0] Note 1: N must be a multiple of 32 bytes Note 2: The max value check code was taken from std::field::to_be_bytes function.