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

Additional methods for Integer and Monty #533

Merged
merged 3 commits into from
Dec 29, 2023

Conversation

fjarri
Copy link
Contributor

@fjarri fjarri commented Dec 29, 2023

  • Add Integer::from_limb_like(), one_like(), and Zero::zero_like(). This is needed in #39
  • Add Monty::params() and as_montgomery()

I do not entirely like from_limb_like, but that's all I could come up with.

src/traits.rs Outdated Show resolved Hide resolved
Comment on lines +166 to +169
/// The value `1` with the same precision as `other`.
fn one_like(other: &Self) -> Self {
Self::from_limb_like(Limb::ONE, other)
}
Copy link
Member

Choose a reason for hiding this comment

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

I've wondered if we should have a One trait, similar to num_traits::One.

The only reason we don't use num_traits::One is so is_one can return Choice, as it were.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems logical to have such a trait. If we're redefining num_traits::Zero, might as well redefine One too.

@tarcieri tarcieri merged commit 553e72e into RustCrypto:master Dec 29, 2023
16 checks passed
@fjarri fjarri deleted the constructors branch December 29, 2023 19:07
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