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: add safe comparators templates #164

Merged
merged 2 commits into from
Feb 21, 2024

Conversation

0xjei
Copy link
Member

@0xjei 0xjei commented Feb 13, 2024

Description

This PR adds the safe comparators (SafeLessThan, SafeLessEqThan, SafeGreaterThan, SafeGreaterEqThan) circom templates. These circuits are pretty much similar to the circomlib ones but they add a conversion of the inputs to compare to their bit representations to ensure they fit within 'n' bits (implicit range check).

Compared to the original version of MACI, Anonymous Components were used, resulting in DX improvement and small optimisation.

Related Issue(s)

see #131

Other information

Checklist

  • My code follows the style guidelines of this project
  • 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
  • My changes generate no new warnings
  • I have run yarn prettier and yarn lint without getting any errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Copy link
Collaborator

@ctrlc03 ctrlc03 left a comment

Choose a reason for hiding this comment

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

Good stuff!!
Just added a style suggestion (comments over variables vs side-by-side) and to optionally add some more tests to ensure all cases are covered. Other than that, LGTM

packages/circuits/circom/safe-comparators.circom Outdated Show resolved Hide resolved
packages/circuits/tests/safe-comparators.test.ts Outdated Show resolved Hide resolved
packages/circuits/tests/safe-comparators.test.ts Outdated Show resolved Hide resolved
@0xjei 0xjei requested a review from ctrlc03 February 14, 2024 16:01
Copy link
Collaborator

@ctrlc03 ctrlc03 left a comment

Choose a reason for hiding this comment

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

Thanks for adding more tests, great stuff

@ctrlc03 ctrlc03 merged commit 401a0e5 into feat/maci-circuits Feb 21, 2024
2 checks passed
@cedoor cedoor deleted the feat/comparators-circuits branch March 1, 2024 12:36
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.

None yet

2 participants