Skip to content

Classic Binary Extended GCD #854

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

Merged
merged 15 commits into from
Jul 3, 2025
Merged

Conversation

erik-3milabs
Copy link
Contributor

@erik-3milabs erik-3milabs commented Jun 24, 2025

This PR introduces the binary extended GCD algorithm, and all the boiler plate code necessary to use the xgcd algorithm.

Supersedes #761.

This was referenced Jun 24, 2025
@erik-3milabs erik-3milabs force-pushed the classic-xgcd branch 3 times, most recently from f4eb716 to b5dd779 Compare June 24, 2025 13:30
@erik-3milabs erik-3milabs marked this pull request as ready for review July 3, 2025 15:47
@erik-3milabs
Copy link
Contributor Author

@tarcieri this PR is ready for review.


pub(crate) struct ExtendedUint<const LIMBS: usize, const EXTENSION_LIMBS: usize>(
Uint<LIMBS>,
Uint<EXTENSION_LIMBS>,
);

impl<const LIMBS: usize, const EXTRA: usize> ExtendedUint<LIMBS, EXTRA> {
/// Construct an [ExtendedUint] from the product of a [Uint<LIMBS>] and an [Uint<EXTRA>].
Copy link
Member

Choose a reason for hiding this comment

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

Using this syntax will linkify the resulting rustdoc:

Suggested change
/// Construct an [ExtendedUint] from the product of a [Uint<LIMBS>] and an [Uint<EXTRA>].
/// Construct an [`ExtendedUint`] from the product of a [`Uint<LIMBS>`] and an [`Uint<EXTRA>`].

Copy link
Member

Choose a reason for hiding this comment

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

Note: there seem to be several instances of this below, including ones I didn't catch before

Copy link
Member

Choose a reason for hiding this comment

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

Going to approve this PR but it would be good to get any of these which are visible in public rustdoc fixed up

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using this syntax will linkify the resulting rustdoc:

You're absolutely correct that it is good thing to add those...

... which I'll have to do that in the next PR, given that you already merged this one 🙈

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(Also, on my end [Uint<LIMBS>] links to Uint and gets displayed as Uint, while

[`Uint<LIMBS>`]

still links to Uint but gets formatted as Uint<LIMBS>.

So, the backticks just add the LIMBS, but not the link.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, there is a difference in the formatting. Adding backticks also formats the word as code, instead of just text.

@tarcieri tarcieri merged commit bbd9f17 into RustCrypto:master Jul 3, 2025
23 checks passed
Copy link

@dolevmu dolevmu left a comment

Choose a reason for hiding this comment

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

Nice!

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