-
Notifications
You must be signed in to change notification settings - Fork 275
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
Add error type for combine keys + test and doc #304
Add error type for combine keys + test and doc #304
Conversation
This is a breaking change - let me check if we can push out a minor release before this. |
Yes. Will need to wait for #305 |
Is it because of deleting |
Yes, though also because we added the other variant that replaces it. |
@@ -395,11 +395,15 @@ impl PublicKey { | |||
|
|||
/// Adds the keys in the provided slice together, returning the sum. Returns | |||
/// an error if the result would be the point at infinity, i.e. we are adding | |||
/// a point to its own negation | |||
/// a point to its own negation, or if the provided slice has no element in it. | |||
pub fn combine_keys(keys: &[&PublicKey]) -> Result<PublicKey, Error> { |
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.
I am not sure whether it is a good practice to return general error type when in fact only a single error subtype may be caused by the function. I think replacing Result<_, Error>
on Result<_, InvalidPublicKeySum>
will do a better job (the caller, if needed, may convert the error into general Error
crate 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.
I can't speak for what is good practice or not, but looking at the rest of the code I feel like doing what you propose would be inconsistent with it, so if that's the way we want to go it might be better to make the change everywhere at once.
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.
Yes, I also have seen that all functions in the lib used to return the single error type, which is a thing is not a good API, but this will certainly require distinct PR
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.
If all of our functions returned distinct error types it would be an extremely unergonomic API, requring downstream users to wrap all of our individual types and implementing From
on them to convert to their own error types.
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.
ack e2e1abf
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.
utACK e2e1abf
674cc79
e2e1abf
to
674cc79
Compare
utACK 674cc79 |
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.
ACK 674cc79
Trying to address the issues raised here:
Deleted the
TweakCheckFailed
at the same time since it's not used but let me know if you'd prefer to have that in a separate commit/PR.@real-or-random I was not sure if you wanted to change something in the fuzz_dummy module and I'm not so familiar with what it does so let me know if it does need a change.