Skip to content

Commit

Permalink
update secp256r1 malleability test
Browse files Browse the repository at this point in the history
  • Loading branch information
alinush committed Jun 5, 2024
1 parent b9a2560 commit dc0ff96
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions crates/aptos-crypto/src/unit_tests/secp256r1_ecdsa_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,11 @@ proptest! {
let sig_unchecked = Signature::from_bytes_unchecked(&serialized);
prop_assert!(sig_unchecked.is_ok());

// Update the signature by setting S = L to make it invalid.
// S = ORDER_HALF should be a canonical signature.
serialized[32..].copy_from_slice(&ORDER_HALF);
let serialized_malleable_l: &[u8] = &serialized;
// try_from will fail with CanonicalRepresentationError.
prop_assert_eq!(
Signature::try_from(serialized_malleable_l),
Err(CryptoMaterialError::CanonicalRepresentationError)
let canonical: &[u8] = &serialized;
prop_assert!(
Signature::try_from(canonical).is_ok()
);
}
}

0 comments on commit dc0ff96

Please sign in to comment.