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

feat(stdlib): EdDSA sig verification #1313

Merged
merged 10 commits into from
May 18, 2023
Merged

Conversation

shuklaayush
Copy link
Contributor

@shuklaayush shuklaayush commented May 7, 2023

Related issue(s)

Resolves #1109
Supercedes #1136
Depends on #1312, #1343

Description

Summary of changes

  • Add a eddsa::eddsa_poseidon_verify function to stdlib
  • Update std::ec functions to use builtin to_bits
  • Create std::compat with a is_bn254 function

Dependency additions / changes

Test additions / changes

Checklist

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt with default settings.
  • I have linked this PR to the issue(s) that it resolves.
  • I have reviewed the changes on GitHub, line by line.
  • I have ensured all changes are covered in the description.

Documentation needs

  • This PR requires documentation updates when merged.

Additional context

@guipublic
Copy link
Contributor

I implemented the to_bits for any field in PR #1343, could you compare the cost between your noir implementation vs the PR?
In my tests, it was only 2% better.

@shuklaayush
Copy link
Contributor Author

shuklaayush commented May 12, 2023

I'm getting a Error: could not satisfy all constraints in this line with your changes

assert(!eddsa_poseidon_verify(pub_key_a.x, pub_key_a.y, s_a, r8_a.x, r8_a.y, msg + 1));

let right = bjj.curve.add(signature_r8, bjj.curve.mul(hash, pub_key_mul_8));

@guipublic
Copy link
Contributor

guipublic commented May 15, 2023

I'm getting a Error: could not satisfy all constraints in this line with your changes

I don't think it is related to the to_bits, I checked the to_bits used and they produce the same version with the noir implementation and with my changes.

UPDATE: Using the ex you provided, I was able to see the issue and it is fixed

@shuklaayush
Copy link
Contributor Author

UPDATE: Using the ex you provided, I was able to see the issue and it is fixed

Thanks, everything seems to work now and total constraints are back to ~145k compared to ~247k constraints in #1312 (comment)

@shuklaayush
Copy link
Contributor Author

@kevaundray This should be good for review

noir_stdlib/src/ec/swcurve.nr Show resolved Hide resolved
noir_stdlib/src/field.nr Outdated Show resolved Hide resolved
Copy link
Contributor

@guipublic guipublic left a comment

Choose a reason for hiding this comment

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

My points have been addressed so for me this is OK to go, but I let final approval to Kev as I did not review the cryptography part.

Copy link
Collaborator

@kevaundray kevaundray left a comment

Choose a reason for hiding this comment

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

Left one question re commented out code

@kevaundray kevaundray enabled auto-merge May 18, 2023 10:15
@kevaundray kevaundray dismissed guipublic’s stale review May 18, 2023 10:19

approved in above comment

@kevaundray kevaundray added this pull request to the merge queue May 18, 2023
Merged via the queue into noir-lang:master with commit 04a15e0 May 18, 2023
5 checks passed
@shuklaayush shuklaayush deleted the fix/eddsa branch May 18, 2023 14:09
TomAFrench added a commit that referenced this pull request May 23, 2023
* phated/acvm-0.12.0:
  fix compilation issue
  switch to published acvm and backend
  feat(nargo): Consume CommonReferenceString functions & manage caching (#1348)
  fix(stdlib): Workaround for Field comparison error in EdDSA signature verification (#1372)
  feat!: remove concept of noir fallbacks for foreign functions (#1371)
  feat(ssa refactor): mem2reg opt pass (#1363)
  feat(stdlib): EdDSA sig verification (#1313)
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.

Add EdDSA verification to standard library
5 participants