bytes_to_packed_u32_felts

Function bytes_to_packed_u32_felts 

Source
pub fn bytes_to_packed_u32_felts(bytes: &[u8]) -> Vec<Felt>
Expand description

Converts bytes to field elements using u32 packing in little-endian format.

Each field element contains a u32 value representing up to 4 bytes. If the byte length is not a multiple of 4, the final field element is zero-padded.

This is commonly used by precompile handlers (Keccak256, ECDSA) to convert byte data into field element commitments.

§Arguments

  • bytes: The byte slice to convert

§Returns

A vector of field elements, each containing 4 bytes packed in little-endian order.

§Examples

let bytes = vec![0x01, 0x02, 0x03, 0x04, 0x05];
let felts = bytes_to_felts(&bytes);
// Returns: [Felt(0x04030201), Felt(0x00000005)]