aztec-nr - noir_aztec::utils::conversion::bytes_to_fields

Function bytes_to_fields

pub fn bytes_to_fields<let N: u32>(bytes: [u8; N]) -> [Field; N / 31]

Converts the input bytes into an array of fields. A Field is ~254 bits meaning that each field can store 31 whole bytes. Use bytes_from_fields to obtain the original bytes array.

The input bytes are chunked into chunks of 31 bytes. Each 31-byte chunk is viewed as big-endian, and is converted into a Field. For example, [1, 10, 3, ..., 0] (31 bytes) is encoded as [1 * 256^30 + 10 * 256^29 + 3 * 256^28 + ... + 0] Note: N must be a multiple of 31 bytes