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

Int - inv_mod #737

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Draft

Conversation

erik-3milabs
Copy link
Contributor

@erik-3milabs erik-3milabs commented Jan 10, 2025

Introduces the Int::inv_mod operation.

Replaces #727

Comment on lines -446 to 449
pub trait InvMod: Sized {
pub trait InvMod<Rhs = Self, Output = Self>: Sized {
/// Compute `1 / self mod p`.
fn inv_mod(&self, p: &Self) -> CtOption<Self>;
fn inv_mod(&self, p: &Rhs) -> CtOption<Output>;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tarcieri this is the non-breaking type approach for this trait. I think a more readable solution would be to add the type Modulus; and type Output; as trait types. Wdyt?

Copy link
Member

Choose a reason for hiding this comment

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

making Output an associated type makes sense, however Rhs is typically a generic parameter in core arithmetic traits, which allows overlapping impls potentially (though I'm not sure that would be of use here)

@erik-3milabs erik-3milabs marked this pull request as ready for review January 10, 2025 17:08
@erik-3milabs erik-3milabs marked this pull request as draft January 10, 2025 17:09
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.

2 participants