validate_field_bytes

Function validate_field_bytes 

Source
pub fn validate_field_bytes(bytes: &[u8]) -> Result<(), MathError>
Expand description

Validate that a byte array represents a valid field element (in [0, p)).

§Arguments

  • bytes - The byte array to validate (must be 32 bytes)

§Returns

Returns Ok(()) if the bytes represent a valid field element, or an error otherwise.

§Errors

Returns MathError::InvalidFieldElement if the value is not in [0, p). Returns MathError::BufferTooSmall or MathError::BufferTooLarge if the buffer size is incorrect.