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

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft

Conversation

ewoolsey
Copy link

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

@ewoolsey
Copy link
Author

ewoolsey 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.

@ewoolsey
Copy link
Author

ewoolsey commented Jul 5, 2024

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!

@ewoolsey
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 :).

@ewoolsey
Copy link
Author

@Tabaie just bumping this one more time 👍

@ewoolsey
Copy link
Author

@Tabaie sorry just bumping this again ahah

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