Skip to content

Conversation

@erik-3milabs
Copy link
Contributor

Introduces the Int::inv_mod operation.

Status: awaiting the merge of #722.

Comment on lines -446 to 449
/// Compute `1 / self mod p`.
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

@erik-3milabs erik-3milabs Jan 8, 2025

Choose a reason for hiding this comment

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

This solution should (in theory?) just be an addition, not a breaking change.

However, perhaps the following solution might be neater:

pub trait InvMod: Sized {

    type Modulus;
    type Output;

    /// Compute `1 / self mod p`.
    fn inv_mod(&self, p: &Self::Modulus) -> Self::Output;
}

@tarcieri let's have a discussion about this to see what works best.

@erik-3milabs erik-3milabs mentioned this pull request Jan 9, 2025
10 tasks
@tarcieri tarcieri deleted the branch RustCrypto:signed-int January 9, 2025 14:44
@tarcieri tarcieri closed this Jan 9, 2025
This was referenced Jan 10, 2025
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