diff --git a/acir_field/src/generic_ark.rs b/acir_field/src/generic_ark.rs index 59600549f..ab13a77e9 100644 --- a/acir_field/src/generic_ark.rs +++ b/acir_field/src/generic_ark.rs @@ -111,6 +111,15 @@ impl From for FieldElement { } } +impl From> for char { + fn from(element: FieldElement) -> Self { + let mut field_as_bytes = element.to_be_bytes(); + let char_byte = field_as_bytes.pop().expect("The last byte should be a char"); // A character in a string is represented by a u8, thus we just want the last byte of the element + assert!(field_as_bytes.into_iter().all(|b| b == 0)); // Assert that the rest of the field element's bytes are empty + char_byte as char + } +} + impl Serialize for FieldElement { fn serialize(&self, serializer: S) -> Result where