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

docs: a few usage examples for div #540

Merged
merged 5 commits into from
Jan 3, 2024
Merged

docs: a few usage examples for div #540

merged 5 commits into from
Jan 3, 2024

Conversation

Dustin-Ray
Copy link
Contributor

@Dustin-Ray Dustin-Ray commented Jan 2, 2024

Adds a few usage examples for div operations. ref issue #283.

Additionally modifies:

pub const fn wrapping_rem

into:

pub const fn wrapping_rem_vartime

since it uses rem_vartime internally.

src/uint/div.rs Outdated
@@ -159,6 +159,19 @@ impl<const LIMBS: usize> Uint<LIMBS> {

/// Computes `self` % 2^k. Faster than reduce since its a power of 2.
/// Limited to 2^16-1 since Uint doesn't support higher.
/// TODO: this is not constant-time.
Copy link
Member

Choose a reason for hiding this comment

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

Sidebar: we should perhaps consider renaming this rem2k_vartime /cc @fjarri

Copy link
Contributor

Choose a reason for hiding this comment

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

I imagine making it constant-time would also be pretty straightforward.

Although I am not sure we need it at all in the API.

src/uint/div.rs Outdated Show resolved Hide resolved
@fjarri
Copy link
Contributor

fjarri commented Jan 3, 2024

I just want to reiterate my position (last time, I promise) that usage examples for simple arithmetic operations like these are entirely excessive.

@Dustin-Ray Dustin-Ray requested a review from tarcieri January 3, 2024 20:04
@Dustin-Ray
Copy link
Contributor Author

I just want to reiterate my position (last time, I promise) that usage examples for simple arithmetic operations like these are entirely excessive.

wrapping_rem_vartime and rem2k_vartime examples might be excessive, if you would like those removed, Im not opposed to it. The others did take me considerable time to get working without examples, it would be nice to leave them if possible.

@Dustin-Ray Dustin-Ray requested a review from fjarri January 3, 2024 20:11
@tarcieri tarcieri merged commit 50c576c into RustCrypto:master Jan 3, 2024
16 checks passed
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.

3 participants