-
Notifications
You must be signed in to change notification settings - Fork 60
div
with differently sized denominators
#799
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
base: master
Are you sure you want to change the base?
Conversation
@@ -124,11 +127,17 @@ impl<const LIMBS: usize> Uint<LIMBS> { | |||
// Copy out the remainder | |||
y[0] = Limb::select(x[0], Limb(rem2), limb_div); | |||
i = 1; | |||
while i < LIMBS { | |||
|
|||
let min = if LIMBS < RHS_LIMBS { LIMBS } else { RHS_LIMBS }; |
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.
From a constant-time perspective, is this ok? I think it is, but perhaps worth spelling out explicitly in a comment? Like "This does not invalidate the constant time contract, because the compiler will eliminate this branch"?
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.
It would be good to have this working when used through traits as well (i.e when I have an Integer
rather than a concrete U1024
). Is that something you can fit into this PR you think?
With this PR in place, denominators are no longer required to be a
Uint
/Int
of the same number of limbs as the numerator, enabling more efficient division.