Skip to content
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

Chain TryFrom errors rather than calling unwrap on them #91

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

xoloki
Copy link
Collaborator

@xoloki xoloki commented Sep 27, 2024

Fixes #89

src/errors.rs Outdated Show resolved Hide resolved
@@ -1,6 +1,6 @@
[package]
name = "wsts"
version = "9.1.0"
version = "10.0.0"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to bump the version, should we remove that unused error variant?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we can go wild here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

/// threshold, where the degree of each poly is (t-1)
t: u32,
t: usize,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious, usize instead of u64 or u32? Same question for neg_shares.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal was to get rid of the conversions inside the C callback, since we can’t return errors from there.

Copy link
Collaborator Author

@xoloki xoloki Sep 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wow get_point still has an as cast 😮

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh I see. Got it.

We use usize because we often feed things into functions in the p256k1 library. That library wraps the libsecp256k1 C library via the rust-bindgen crate. And bindgen assumes size_t is usize (which is the default). We can change that default but keeping things as is allows p256k1 to be used on rust targets where the pointer size is not 64-bits.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we need to do another pass on usize vs explicitly sized types. Anything that doesn’t go over the network is probably better s as usize.

@djordon
Copy link

djordon commented Oct 2, 2024

Can we also replace the hashbrown:HashMap type with the one from the standard library?

@xoloki
Copy link
Collaborator Author

xoloki commented Oct 2, 2024

Can we also replace the hashbrown:HashMap type with the one from the standard library?

Yeah. I had aspirations of making this no_std at one point, or putting the std code behind a feature gate. But no one seems to care so much about no_std these days.

@djordon
Copy link

djordon commented Oct 2, 2024

Yeah. I had aspirations of making this no_std at one point, or putting the std code behind a feature gate. But no one seems to care so much about no_std these days.

Ahh I see. Yeah, I was wondering why that was used. Well, if that ends up being a goal again we can change it back or something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove usage of try_into().unwrap() where feasible
2 participants