/// Verifies that conversions between a value and a test vector work as
/// expected.
Verifies that conversions between a value and a test vector work as
expected.
Verifies that conversions between a value and a test vector work as expected .
fn g2_serde_should_be_correct(hex_test_vector: &str, value: &ECP2, test_name: &str) {
    let serialised = miracl_g2_to_bytes(value).0;
    assert_eq!(
        hex_test_vector,
        hex::encode(&serialised[..]),
        "Serialisation does not match for {}",
        test_name
    );
    let bytes = hex::decode(hex_test_vector).expect("Invalid test vector hex encoding");
    let bytes = g2_bytes_from_vec(&bytes);
    let parsed = miracl_g2_from_bytes(&bytes).expect("Failed to parse test vector");
    assert!(
        parsed.equals(value),
        "Parsed value does not match for {} {}",
        test_name,
        {
            let mut neg = parsed;
            neg.neg();
            if neg.equals(value) {
                "due to sign error"
            } else {
                ""
            }
        }
    );
}
fn g2_serde_should_be_correct ( hex_test_vector : & str , value : & ECP2 , test_name : & str ) { let serialised = miracl_g2_to_bytes ( value ) . 0 ; assert_eq ! ( hex_test_vector hex encode ( serialised [ ] ) " " test_name ) ; let bytes = hex :: decode ( hex_test_vector ) . expect ( " " ) ; let bytes = g2_bytes_from_vec ( & bytes ) ; let parsed = miracl_g2_from_bytes ( & bytes ) . expect ( " " ) ; assert ! ( parsed equals ( value ) " " test_name { let mut neg parsed neg neg ( ) if neg equals ( value ) { " " } else { " " } } ) ; }
Verifies that conversions between a value and a test vector work as
expected.
Verifies that conversions between a value and a test vector work as expected .
hex_test_vector
&str
value
&ECP2
test_name
&str