Skip to content

Commit a66f581

Browse files
authored
Merge pull request #296 from sanket1729/seckey_fromstr
Fix SecretKey FromStr bug
2 parents b48d1ea + 6265b25 commit a66f581

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/key.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl str::FromStr for SecretKey {
5151
fn from_str(s: &str) -> Result<SecretKey, Error> {
5252
let mut res = [0; constants::SECRET_KEY_SIZE];
5353
match from_hex(s, &mut res) {
54-
Ok(constants::SECRET_KEY_SIZE) => Ok(SecretKey(res)),
54+
Ok(constants::SECRET_KEY_SIZE) => SecretKey::from_slice(&res),
5555
_ => Err(Error::InvalidSecretKey)
5656
}
5757
}
@@ -525,6 +525,10 @@ mod test {
525525
fn invalid_secret_key() {
526526
// Zero
527527
assert_eq!(SecretKey::from_slice(&[0; 32]), Err(InvalidSecretKey));
528+
assert_eq!(
529+
SecretKey::from_str(&format!("0000000000000000000000000000000000000000000000000000000000000000")),
530+
Err(InvalidSecretKey)
531+
);
528532
// -1
529533
assert_eq!(SecretKey::from_slice(&[0xff; 32]), Err(InvalidSecretKey));
530534
// Top of range

0 commit comments

Comments
 (0)