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

Add entry inequality module to GPC #1892

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

ax0
Copy link
Collaborator

@ax0 ax0 commented Sep 20, 2024

This PR adds an entry inequality module to GPCs. Summary of changes:

  • Addition of entry inequality module to gpcircuits package.
  • Changes to ProtoPODGPC circuit.
  • Addition of optional lessThan, lessThanEq, greaterThan and greaterThanEq fields to the GPC proof entry config.
  • Changes to GPC config compiler.
  • Corresponding tests.

This PR depends on the artifact changes in proofcarryingdata/snark-artifacts#14.

packages/lib/gpcircuits/circuits/entry-inequality.circom Outdated Show resolved Hide resolved
"maxLists": 0,
"maxListElements": 0,
"maxTuples": 0,
"tupleArity": 0,
"includeOwnerV3": true,
"includeOwnerV4": false
},
6842
6843
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like something is costing 1 constraint even when the number of EI modules is zero.
Do you have any insight into what it is? Not a big deal, but I'd expect everything to collapse to zero.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This comes from the bit-packed signal associated with the module.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Num2Bits(0) has a constraint? Naughty.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Literally naught-y in the sense that Num2Bits(0) constrains its input to be zero. ;-)

packages/lib/gpcircuits/circuits/entry-inequality.circom Outdated Show resolved Hide resolved
// NumericValueModule}.
signal output out <== LessThan(NUM_BITS)(
[
value + ABS_POD_INT_MIN(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel like this "offset value" should be a template parameter rather than being hard-coded here. The proto-pod-gpc layer should be where the decision on int size is made. The same suggestion might apply to the bounds check module too. Actually it could be a template parameter at the proto-pod-gpc level too, though that might be overkill since I don't anticipate ever generating with different sizes.

packages/lib/gpcircuits/test/entry-inequality.spec.ts Outdated Show resolved Hide resolved
packages/lib/gpc/src/gpcChecks.ts Outdated Show resolved Hide resolved
packages/lib/gpc/src/gpcChecks.ts Outdated Show resolved Hide resolved
packages/lib/gpc/src/gpcChecks.ts Outdated Show resolved Hide resolved
packages/lib/gpc/src/gpcCompile.ts Outdated Show resolved Hide resolved
packages/lib/gpc/src/gpcCompile.ts Show resolved Hide resolved
@ax0 ax0 requested a review from artwyman September 21, 2024 01:04
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.

2 participants