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

[Field] Converting 'negative' finite field elements to negative integers #68

Merged
merged 1 commit into from
Apr 14, 2020

Conversation

effectfully
Copy link
Owner

@effectfully effectfully commented Apr 10, 2020

Now asInteger (toInteger (-1) :: AField Jubjub.F) gives Just (-1) instead of 52435875175126190479447740508185965837690552500527637822603658699938581184512.

@effectfully effectfully requested review from kwxm and jakzale April 10, 2020 19:16
stack.yaml Show resolved Hide resolved
Copy link
Collaborator

@jakzale jakzale left a comment

Choose a reason for hiding this comment

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

lgtm.

p = natVal @p Proxy
i = GF.fromP f
asInteger x
| i < p `Prelude.div` 2 = Just i
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does the edge case of i == p `Prelude.div` 2 matter here. I am not sure.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I started checking that and realized the whole test is broken and doesn't test what it's supposed to. Will fix.

@effectfully effectfully force-pushed the effectfully/field/drop-IsNegative branch from 301b40e to 007a8b7 Compare April 13, 2020 16:53
@effectfully
Copy link
Owner Author

Ready for another review. Now we have a test that shows how overflows are handled and the old test now uses Large Int instead of Integer as that has no chance of overflowing.

test/Field/Axioms.hs Show resolved Hide resolved
@effectfully effectfully merged commit 30ae294 into master Apr 14, 2020
@effectfully effectfully deleted the effectfully/field/drop-IsNegative branch April 14, 2020 13:53
@effectfully effectfully mentioned this pull request Apr 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants