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

fix: strict ModReduce in emulated fields #1224

Merged
merged 12 commits into from
Jul 25, 2024
Merged

fix: strict ModReduce in emulated fields #1224

merged 12 commits into from
Jul 25, 2024

Conversation

ivokub
Copy link
Collaborator

@ivokub ivokub commented Jul 24, 2024

Description

Fixes #1147, but more thoroughly. Added separate method which performs modular reduction and asserts that the result is in range. Updated the documentation accordingly.

Additionally, added an option to algebra methods to obtain the canonical bit representation if necessary (when comparing bitwise some values).

The current implementation are not modified - if the prover would provide x+p from the hint, then the recursion implementations fail to solve as we have incorrect FS challenges.

We now have reduction in the 2-chain PLONK verifier as previously when performing binary decomposition of BLS12 points we used canonical decomposition, but now by default we don't.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How has this been tested?

  • TestReduceStrict
  • TestToBitsCanonical
  • TestIsZeroEdgeCases

How has this been benchmarked?

  • PLONK verify BLS12-377 in BW6-761. Was 358153 now 322251
  • PLONK verify BW6-761 in BN254. Was 28933345 now 28215408.

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
  • Any dependent changes have been merged and published in downstream modules

@ivokub ivokub added consolidate strengthen an existing feature doc labels Jul 24, 2024
@ivokub ivokub requested a review from gbotrel July 24, 2024 13:27
@ivokub ivokub self-assigned this Jul 24, 2024
@ivokub ivokub marked this pull request as draft July 24, 2024 13:43
@ivokub
Copy link
Collaborator Author

ivokub commented Jul 24, 2024

Converting to draft until bugs fixed.

@ivokub ivokub marked this pull request as ready for review July 24, 2024 15:20
std/math/emulated/field_assert.go Show resolved Hide resolved
std/math/emulated/field_assert.go Show resolved Hide resolved
std/math/emulated/field_binary.go Show resolved Hide resolved
std/math/emulated/field_binary.go Show resolved Hide resolved
std/math/emulated/field_reduce.go Outdated Show resolved Hide resolved
@ivokub
Copy link
Collaborator Author

ivokub commented Jul 25, 2024

Fixes pushed.

@ivokub ivokub requested a review from gbotrel July 25, 2024 09:08
@ivokub ivokub merged commit af21593 into master Jul 25, 2024
7 checks passed
@ivokub ivokub deleted the feat/strict-modreduce branch July 25, 2024 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consolidate strengthen an existing feature doc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: describe in emulated Reduce method that the result may be either x or x+p
2 participants