-
Notifications
You must be signed in to change notification settings - Fork 56
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
Boxed uintlike coverage #428
Conversation
e2819ce
to
db33158
Compare
src/modular/boxed_residue.rs
Outdated
let (half, is_odd) = a.shr1_with_carry(); | ||
let half_modulus = modulus.shr1(); | ||
|
||
let if_even = half.clone(); | ||
let if_odd = half | ||
.wrapping_add(&half_modulus) | ||
.wrapping_add(&BoxedUint::one_with_precision(a.bits_precision())); | ||
|
||
BoxedUint::conditional_select(&if_even, &if_odd, is_odd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can cut down on a number of allocations here:
let (half, is_odd) = a.shr1_with_carry(); | |
let half_modulus = modulus.shr1(); | |
let if_even = half.clone(); | |
let if_odd = half | |
.wrapping_add(&half_modulus) | |
.wrapping_add(&BoxedUint::one_with_precision(a.bits_precision())); | |
BoxedUint::conditional_select(&if_even, &if_odd, is_odd) | |
let (mut ret, is_odd) = a.shr1_with_carry(); | |
let half_modulus = modulus.shr1(); | |
let if_odd = ret | |
.wrapping_add(&half_modulus) | |
.wrapping_add(&BoxedUint::one()); | |
ret.conditional_assign(&if_odd, is_odd); | |
ret |
Cargo.toml
Outdated
@@ -39,7 +39,7 @@ rand_core = { version = "0.6", features = ["std"] } | |||
rand_chacha = "0.3" | |||
|
|||
[features] | |||
default = ["rand"] | |||
default = ["rand", "alloc"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the downstream crates which use this crate don't need the alloc
feature. It's really just for rsa
/dsa
.
8602622
to
b01e8bb
Compare
This is an attempt to implement for
BoxedUint
the missing arithmetic needed forcrypto-primes
(see entropyxyz/crypto-primes#37 (comment)).