-
Notifications
You must be signed in to change notification settings - Fork 5
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
Uint traits #39
Uint traits #39
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #39 +/- ##
==========================================
- Coverage 99.21% 98.48% -0.73%
==========================================
Files 9 10 +1
Lines 1402 1521 +119
==========================================
+ Hits 1391 1498 +107
- Misses 11 23 +12 ☔ View full report in Codecov by Sentry. |
Two other possible strategies for dealing with precision:
|
Personally I prefer explicit over implicit. Having "automatic" widening thus doesn't sound too appealing. Having a one/zero as an instance method also sound awkward. Some of the places where "one" is used are for "minus by one". For that I think having a "wrapping/overflowing decrement/increment" method would make a lot of sense. In other places, I think having an explicit "*_with_precision" and "widen" functions is the least awkward of all the awkward solutions. |
RustCrypto/crypto-bigint#312 is the tracking issue for where it might sense to implement automatic widening. Several operations do already support it. It's actually fairly important for performance as it can cut down on the total number of operations that need to be performed versus explicitly widening the inputs to be the same size. So long as those widths are always fixed (for e.g. a given key size) the result is still constant-time. RustCrypto/crypto-bigint#403 includes some additional widening support. |
} else { | ||
let abs_q = MontyForm::<L>::new(&Uint::<L>::from(abs_q), params); | ||
let abs_q = <T as Integer>::Monty::new( | ||
T::from(abs_q).widen(candidate.bits_precision()), |
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.
When instantiating BoxedMontyForm::new(residue, params)
, the current behavior is to panic when the residue's precision is not equal to the parameter's precision. Should this be changed to "automatic widening"?
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.
Sure, sounds good
@fjarri I've kind of wanted something like that but have also been stuck on the name |
If it's a "static" method, we could follow |
For that particular application, I was thinking something which accepts |
I just think that in case of the static method the naming is easier. |
Aah, yeah, makes sense |
I finally dissolved the |
v0.6.0-pre.6 is out: RustCrypto/crypto-bigint#527 |
I'm on vacation at this moment so apologies in advance for slow progress. |
This PR builds upon #36 and adds the following items:
presets.rs
:prime_generation_boxed
andsafe_prime_generation_boxed
, both of which passoverflowing_shl_vartime
andoverflowing_shr_vartime
, as well asrandom_bits
forBoxedUint
one_with_precision
,zero_with_precision
, andwiden
toUintLike
so that allBoxedUint
sizes can be kept identicalmiller_rabin.rs
andlucas.rs
to maintain equalBoxedUint
sizes across the entire module.The most awkward part of these proposed changes is the need for
one_with_precision
,zero_with_precision
, andwiden
, which makes sense in the context ofBoxedUint
but feels redundant when working withUint
. Again, I think some clear documentation will suffice, but maybe there are some better ways.cc: @fjarri