Skip to content

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
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
@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?

3 participants