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

Add Odd newtype #487

Merged
merged 9 commits into from
Dec 21, 2023
Merged

Add Odd newtype #487

merged 9 commits into from
Dec 21, 2023

Conversation

tarcieri
Copy link
Member

@tarcieri tarcieri commented Dec 20, 2023

Adds a newtype similar to NonZero which identifies odd integers at the type level.

This can be used for infallible conversions for moduli, i.e. reusing a *MontParams modulus as a Bernstein-Yang modulus infallibly.

Closes #479

@tarcieri tarcieri requested a review from fjarri December 20, 2023 19:47
src/modular/monty_form.rs Outdated Show resolved Hide resolved
Comment on lines 144 to 145
assert!(a < P);
assert!(b < P);
assert!(a < *P);
assert!(b < *P);
Copy link
Member Author

@tarcieri tarcieri Dec 20, 2023

Choose a reason for hiding this comment

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

A PartialOrd<Odd<Uint<LIMBS>> impl for Uint<LIMBS> might be handy here

@tarcieri tarcieri force-pushed the odd-newtype branch 2 times, most recently from 37b0d6b to c9bad93 Compare December 20, 2023 23:17
@tarcieri
Copy link
Member Author

tarcieri commented Dec 20, 2023

Still needs Boxed* support but it should be good for everything stack-allocated Edit: done

@tarcieri tarcieri requested a review from fjarri December 21, 2023 01:56
Adds a newtype similar to `NonZero` which identifies odd integers at the
type level.

This can be used for infallible conversions for moduli, i.e. reusing a
`*MontParams` modulus as a Bernstein-Yang modulus infallibly.
This makes the constructors infallible
@tarcieri tarcieri merged commit 747f0ca into master Dec 21, 2023
16 checks passed
@tarcieri tarcieri deleted the odd-newtype branch December 21, 2023 03:57
@tarcieri tarcieri mentioned this pull request Jan 22, 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.

Odd wrapper type?
2 participants