Skip to content

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

erik-3milabs
Copy link
Contributor

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.

@@ -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 };
Copy link
Contributor

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

Copy link
Contributor

@dvdplm dvdplm left a 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?

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.

2 participants