Skip to content

Commit

Permalink
Merge pull request #207 from sorpaas/sp-message-zero
Browse files Browse the repository at this point in the history
Allow all-zero messages
  • Loading branch information
apoelstra committed Aug 26, 2020
2 parents 89541ec + 9250ae4 commit 5c451f7
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/lib.rs
Expand Up @@ -492,10 +492,6 @@ impl Message {
/// [secure signature](https://twitter.com/pwuille/status/1063582706288586752).
#[inline]
pub fn from_slice(data: &[u8]) -> Result<Message, Error> {
if data == [0; constants::MESSAGE_SIZE] {
return Err(Error::InvalidMessage);
}

match data.len() {
constants::MESSAGE_SIZE => {
let mut ret = [0; constants::MESSAGE_SIZE];
Expand Down Expand Up @@ -1087,10 +1083,7 @@ mod tests {
Err(InvalidMessage));
assert_eq!(Message::from_slice(&[0; constants::MESSAGE_SIZE + 1]),
Err(InvalidMessage));
assert_eq!(
Message::from_slice(&[0; constants::MESSAGE_SIZE]),
Err(InvalidMessage)
);
assert!(Message::from_slice(&[0; constants::MESSAGE_SIZE]).is_ok());
assert!(Message::from_slice(&[1; constants::MESSAGE_SIZE]).is_ok());
}

Expand Down

0 comments on commit 5c451f7

Please sign in to comment.