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

Add secp256r1 curve #34

Merged
merged 3 commits into from
Jun 17, 2023
Merged

Conversation

rrrliu
Copy link
Contributor

@rrrliu rrrliu commented Mar 30, 2023

Adds new directory secp256r1 that adds the NIST P-256 curve and its relevant arithmetic operations.

To do this, also modified the macros in src/derive/curve.rs to account for curves where a ≠ 0. Because bn256 and secp256k1 both have a = 0, the elliptic curve operations (add(), double(), is_on_curve(), etc) used calculations that made this assumption. Since secp256r1 has a = 0xfff...fffc, these operations needed to be refactored.

Tests mirror those of the secp256k1 curve. Additionally added a test that checks the ZETA value of the curve.

Thank you to @CPerezz for helping me debug the tests and @enricobottazzi for investigating this library!

@kilic kilic self-requested a review April 4, 2023 17:30
@CPerezz CPerezz self-requested a review June 1, 2023 08:30
Copy link
Member

@CPerezz CPerezz left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for this work and apologies for the delay on the review..

Could @davidnevadoc or @kilic take another look to this prior to merging?

Copy link
Member

@CPerezz CPerezz left a comment

Choose a reason for hiding this comment

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

I oversaw the ROOT_OF_UNITY with the TODO. We should fix it as it is what is causing the errors in the tests probably.

src/bn256/fq.rs Outdated
// TODO: Can we simply put 0 here::
const ROOT_OF_UNITY: Fq = Fq::zero();
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is correct. We should actually look for the correct root. (I belive we already saw in Vietnam there's only 1).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated! @CPerezz can we try re-running the tests? They all pass locally.

@CPerezz
Copy link
Member

CPerezz commented Jun 5, 2023

Hey @rrrliu have you made sure the PR is up-to-date with upstream??

Also, there seems to be some issues related to the version of the group and ff traits which should be in 0.13 both.

@davidnevadoc
Copy link
Contributor

Sure! I'll have a look once the failing checks are fixed :)

@rrrliu
Copy link
Contributor Author

rrrliu commented Jun 11, 2023

Just rebased main and fixed tests!

@davidnevadoc
Copy link
Contributor

Some tests are still failing @rrrliu. I'll review once those are fixed 👍

@CPerezz CPerezz merged commit fad8a00 into privacy-scaling-explorations:main Jun 17, 2023
@CPerezz
Copy link
Member

CPerezz commented Jun 17, 2023

I accidentally merged this. And somehow I can't seem to bring it back.. I probably screwed something up while editing the PR.

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