Skip to content
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

Use Euclid to compute the inverse faster #698

Merged
merged 4 commits into from
Jan 11, 2023
Merged

Conversation

Oppen
Copy link
Contributor

@Oppen Oppen commented Jan 9, 2023

Also update changelog

@Oppen Oppen marked this pull request as ready for review January 9, 2023 21:07
Clippy would complain for the non-obvious presence of a multiplication
in the implementation of a division. This is correct for prime fields,
so there's now a local allow for that warning.
Copy link
Collaborator

@juanbono juanbono left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Also I left some comments

felt/src/bigint_felt.rs Show resolved Hide resolved
felt/src/bigint_felt.rs Show resolved Hide resolved
Copy link
Collaborator

@azteca1998 azteca1998 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to suggest using CAIRO_PRIME to avoid both conversions and .unwrap(), but the algorithm doesn't seem to work properly without negative numbers available.

@Oppen
Copy link
Contributor Author

Oppen commented Jan 11, 2023

I was going to suggest using CAIRO_PRIME to avoid both conversions and .unwrap(), but the algorithm doesn't seem to work properly without negative numbers available.

There's a bug in BigUint for the extended GCD algorithm where they fail to consider at least one of the Bézout coefficients for two coprimes will be negative, so there's a substraction that ends up in a panic due to having to return unsigned.

@Oppen Oppen merged commit 43b4ffd into main Jan 11, 2023
@Oppen Oppen deleted the hotfix-optimization-hotfix branch January 11, 2023 12:06
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.

3 participants