-
Notifications
You must be signed in to change notification settings - Fork 993
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(identity): mark sign as infaillible #5728
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Did leave some comments.
@@ -176,12 +178,12 @@ impl Keypair { | |||
/// Sign a message using the private key of this keypair, producing | |||
/// a signature that can be verified using the corresponding public key. | |||
#[allow(unused_variables)] | |||
pub fn sign(&self, msg: &[u8]) -> Result<Vec<u8>, SigningError> { | |||
pub fn sign(&self, msg: &[u8]) -> Result<Vec<u8>, Infallible> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are returning Ok
throughout the inner functions, should we go on and remove the Result
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can. But what about upstream? there are a couple of functions that return a Result
only because sign
does so. Should we address them here? The biggest change will be noise security upgrade become infallible but the trait bound in swarm builder expect an associated Error
type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could change it so it is no longer expecting an associated error type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im not against making the change here. Thoughts on that @jxs ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I think if it's api that doesn't make sense we should address it and take the next release cycle to release a new libp2p-identity
release wdyt?
@@ -90,7 +90,7 @@ impl Keypair { | |||
self, | |||
id_keys: &identity::Keypair, | |||
) -> Result<AuthenticKeypair, Error> { | |||
let sig = id_keys.sign(&[STATIC_KEY_DOMAIN.as_bytes(), self.public.as_ref()].concat())?; | |||
let sig = id_keys.sign(&[STATIC_KEY_DOMAIN.as_bytes(), self.public.as_ref()].concat()).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto; we should use expect
here to provide context if it ever does fails and panics. Unlikely though but its more of a just-in-case.
Description
A minimal working example of making
Keypair::sign
infaillible.Refer to #4650 for more detail.
Notes & open questions
Change checklist