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

MPC Generated Pedersen Keys #1180

Merged
merged 8 commits into from
Oct 2, 2024

Conversation

0xForerunner
Copy link

@0xForerunner 0xForerunner commented Jun 27, 2024

Description

Some circuits require that the pedersen key is MPC generated.

I'm opening this up as a draft PR as I'd like to gather some feedback on it! Additionally, it will require that encoding for [][]curve.G1Affine is supported in gnark-crypto. Once I've got the go ahead from one of the maintainers I'll proceed with the encoding work upstream and properly updating the templates.

This change involves adding a couple fields to both Phase2Evaluations and Phase2 which represent the G1 points of the Pedersen keys. Phase2.Contribute() then handles the MPC contributions like you'd expect.

Breaking changes include the addition of the new struct fields, as well as the change of arguments in ExtractKeys

Fixes

#1046
#1136

Type of change

  • New feature

How has this been tested?

  • ✅ TestEcdsa

Checklist:

  • ✅ I have performed a self-review of my code
  • ✅ I have commented my code, particularly in hard-to-understand areas
  • ✅ I have made corresponding changes to the documentation
  • ✅ I have added tests that prove my fix is effective or that my feature works
  • 🚫 I did not modify files generated from templates
  • golangci-lint does not output errors locally
  • ✅ New and existing unit tests pass locally with my changes

@CLAassistant
Copy link

CLAassistant commented Jun 27, 2024

CLA assistant check
All committers have signed the CLA.

@0xForerunner
Copy link
Author

0xForerunner commented Jul 5, 2024

Just commenting here for a bump! @ivokub or @Tabaie Would love to get your thoughts.

@Tabaie
Copy link
Contributor

Tabaie commented Jul 5, 2024

Hi @ewoolsey apologies for the delay it's been very busy recently. Will review asap.

@0xForerunner
Copy link
Author

Hi @ewoolsey apologies for the delay it's been very busy recently. Will review asap.

All good, thanks so much for taking a look! I don't see any reason why this shouldn't be the default behaviour, but if you see any issues let me know!

Comment on lines 248 to 258
// Update BasisExpSigma with δ
// TODO: Is it sound to use the same δ for all basis?
for i := 0; i < len(c.Parameters.G1.BasisExpSigma); i++ {
for j := 0; j < len(c.Parameters.G1.BasisExpSigma[i]); j++ {
c.Parameters.G1.BasisExpSigma[i][j].ScalarMultiplication(&c.Parameters.G1.BasisExpSigma[i][j], &deltaBI)
}
}

// Update GRootSigmaNeg using δ⁻¹
c.Parameters.G2.GRootSigmaNeg.ScalarMultiplication(&c.Parameters.G2.GRootSigmaNeg, &deltaInvBI)

Choose a reason for hiding this comment

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

aren't we supposed to verify the ratio of this in verifyPhase2 function?

Copy link
Author

Choose a reason for hiding this comment

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

@hussein-aitlahcen yep that's correct! Sorry for the slow reply, I've been away for the week! I'll push an update for this in an hour or so!

Choose a reason for hiding this comment

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

I've actually patched my fork with your change, rebased on top of main and added the verification if you want to absorb it hussein-aitlahcen@9d859af. I also fixed the cloning of the phase2 which was missing the pedersen key/marshalling and was able to do a full mpc round using this.

Copy link
Author

Choose a reason for hiding this comment

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

@hussein-aitlahcen Thanks for doing that! I've just committed your changes to this PR. Although it might be nice to eventually upstream the marshaling stuff.

I'm getting some issues with verification though it seems.

Copy link

@hussein-aitlahcen hussein-aitlahcen Jul 23, 2024

Choose a reason for hiding this comment

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

What error are you getting? I'm able to do phase2 init + contrib + verification. Did it a couple of time. I think I also inverted GRootSigmaNeg to be mul by deltaBI instead of deltaInvBI. Also if you didn't fix the cloning it won't work.

Copy link
Author

Choose a reason for hiding this comment

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

Ah I manually recreated your fix but copy and pasted wrong. Just cherry picked and now things seem to be working!

@0xForerunner
Copy link
Author

@hussein-aitlahcen thanks so much for the initial review. If you think this is good to go ahead now then I'll go ahead and translate these changes into the templates.

@hussein-aitlahcen
Copy link

@hussein-aitlahcen thanks so much for the initial review. If you think this is good to go ahead now then I'll go ahead and translate these changes into the templates.

Maybe @Tabaie could double check what we did please? I'm not a cryptographer :).

@0xForerunner
Copy link
Author

@Tabaie just bumping this one more time 👍

@0xForerunner
Copy link
Author

@Tabaie sorry just bumping this again ahah

@Tabaie Tabaie changed the base branch from master to feat/pedersen-mpc October 2, 2024 21:19
@Tabaie Tabaie self-requested a review October 2, 2024 21:19
Copy link
Contributor

@Tabaie Tabaie left a comment

Choose a reason for hiding this comment

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

Thank you @ewoolsey. Merging into another branch to make some edits (the Pedersen interface has changed since your PR)

@Tabaie Tabaie marked this pull request as ready for review October 2, 2024 21:22
@Tabaie Tabaie merged commit 7a0d909 into Consensys:feat/pedersen-mpc Oct 2, 2024
2 of 3 checks passed
@0xForerunner
Copy link
Author

Thanks so much for taking a look @Tabaie. Let me know if there's anything you need from me!

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.

4 participants