Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
add tests for from_hex and to_hex (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevaundray authored Feb 10, 2023
1 parent 618a2f4 commit 7704246
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions acir_field/src/generic_ark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,28 @@ mod test {
assert_eq!(res.to_be_bytes(), x.to_be_bytes());
}
}

#[test]
fn serialize_fixed_test_vectors() {
// Serialized field elements from of 0, -1, -2, -3
let hex_strings = vec![
"0000000000000000000000000000000000000000000000000000000000000000",
"30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000",
"30644e72e131a029b85045b68181585d2833e84879b9709143e1f593efffffff",
"30644e72e131a029b85045b68181585d2833e84879b9709143e1f593effffffe",
];

for (i, string) in hex_strings.into_iter().enumerate() {
let minus_i_field_element =
-crate::generic_ark::FieldElement::<ark_bn254::Fr>::from(i as i128);
assert_eq!(minus_i_field_element.to_hex(), string)
}
}
#[test]
fn max_num_bits_smoke() {
let max_num_bits_bn254 = crate::generic_ark::FieldElement::<ark_bn254::Fr>::max_num_bits();
assert_eq!(max_num_bits_bn254, 254)
}
}

fn mask_vector_le(bytes: &mut [u8], num_bits: usize) {
Expand Down

0 comments on commit 7704246

Please sign in to comment.