-
Notifications
You must be signed in to change notification settings - Fork 596
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
Added Cairo inv_mod function #3172
Conversation
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.
Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @yuvalsw)
corelib/src/math.cairo
line 63 at r1 (raw file):
if sub_direction { let (_, inv) = TDivRemImpl::div_rem(s, n); Option::Some(inv)
Suggestion:
// Extended gcd returns `s` <= [n / 2*g] - so it is already in range.
Option::Some(s)
corelib/src/math.cairo
line 68 at r1 (raw file):
// sufficient to add `n` to make sure we have an unsigned integer. let (_, inv) = TDivRemImpl::div_rem(n.into() - s, n); Option::Some(inv)
Suggestion:
// The absolute values of Bezout coefficients are guaranteed to be `< n`,
// so it will never be 0, so it is sufficient to return `n - s` to get a number in the correct range.
Option::Some(n.into() - s)
988f10b
to
7a8e2c5
Compare
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.
Reviewable status: 0 of 6 files reviewed, 2 unresolved discussions (waiting on @orizi)
corelib/src/math.cairo
line 63 at r1 (raw file):
if sub_direction { let (_, inv) = TDivRemImpl::div_rem(s, n); Option::Some(inv)
Done.
corelib/src/math.cairo
line 68 at r1 (raw file):
// sufficient to add `n` to make sure we have an unsigned integer. let (_, inv) = TDivRemImpl::div_rem(n.into() - s, n); Option::Some(inv)
Done.
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.
Reviewed 6 of 6 files at r5, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @yuvalsw)
This change is