Skip to content

feat(stdlib): EdDSA sig verification#1313

Merged
kevaundray merged 10 commits intonoir-lang:masterfrom
shuklaayush:fix/eddsa
May 18, 2023
Merged

feat(stdlib): EdDSA sig verification#1313
kevaundray merged 10 commits intonoir-lang:masterfrom
shuklaayush:fix/eddsa

Conversation

@shuklaayush
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

@kevaundray This should be good for review

Comment thread noir_stdlib/src/ec/swcurve.nr
Comment thread noir_stdlib/src/field.nr Outdated
@shuklaayush shuklaayush requested a review from guipublic May 16, 2023 15:48
Copy link
Copy Markdown
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.

Comment thread noir_stdlib/src/ec/swcurve.nr Outdated
Comment thread crates/nargo_cli/tests/test_data/eddsa/src/main.nr
Comment thread crates/nargo_cli/tests/test_data/eddsa/src/main.nr
Comment thread crates/nargo_cli/tests/test_data/eddsa/src/main.nr
Comment thread noir_stdlib/src/ec/tecurve.nr Outdated
Copy link
Copy Markdown
Contributor

@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
@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