Skip to content

Commit

Permalink
Simplify node announcement signature verification
Browse files Browse the repository at this point in the history
  • Loading branch information
contrun committed Jan 21, 2025
1 parent 5ecc56c commit 4ca98fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 23 deletions.
13 changes: 6 additions & 7 deletions src/fiber/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2079,13 +2079,12 @@ fn verify_node_announcement<S: GossipMessageStore>(
)));
}
}
let message = node_announcement.message_to_sign();
match node_announcement.signature {
Some(ref signature) if signature.verify(&node_announcement.node_id, &message) => Ok(false),
_ => Err(Error::InvalidParameter(format!(
"Node announcement message signature verification failed: {:?}",
&node_announcement
))),
if !node_announcement.verify() {
Err(Error::InvalidParameter(
"Node announcement message signature verification failed".to_string(),
))
} else {
Ok(false)
}
}

Expand Down
21 changes: 5 additions & 16 deletions src/fiber/tests/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,22 +260,11 @@ fn test_create_and_verify_node_announcement() {
now_timestamp_as_millis_u64(),
0,
);
let message = node_announcement.message_to_sign();
match node_announcement.signature {
Some(ref signature) => {
assert!(
signature.verify(&node_announcement.node_id, &message),
"Node announcement message signature verification failed: {:?}",
&node_announcement
);
}
_ => {
panic!(
"Node announcement signature is None: {:?}",
&node_announcement
);
}
}
assert!(
node_announcement.verify(),
"Node announcement message signature verification failed: {:?}",
&node_announcement
);
}

#[test]
Expand Down

0 comments on commit 4ca98fc

Please sign in to comment.