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 Groth16 Circom Adapter #959

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

erhant
Copy link
Contributor

@erhant erhant commented Jan 11, 2025

Fix Groth16 Circom Adapter

Description

  1. This PR fixes bug: groth16 circom-adapter incorrect public signals #958 which is mainly due to the way public signals were handled in Circom adapter. It appears that we can keep the Circom ordering as-is, without adjusting LRO or witness signals which used to do:
  • Circom: ["1", ..outputs, ...inputs, ...other_signals]
  • Lambda: ["1", ...inputs, ..outputs, ...other_signals]
  1. We also change the way public signals are calculated, before it only cared about public inputs but now it counts for public inputs and public outputs as well.

  2. circom_to_lambda now returns the public signals as well, to not let the user shoot themselves in the foot while computing it as it is different than expected with the addition of constant term at the start. (e.g. if public signals are a, b you will actually get 1, a, b.

  3. We add a CircomR1CS type which helps with several things:

  • we use a well-defined type instead of generic Value with many as_TYPE().unwrap() as TYPEs around the place
  • we add deserialization for the FrElement within the object itself
  • we use BufReader with serde_json::from_reader instead of from_str for performance
  1. Removed some redundant clones and tidied up some parts of the code.

  2. Docs will be updated 🚧

  3. Changed the folder structure to be more inline with Cargo recommendations, mainly that tests folder has the integration tests and one test file per test scenario.

Type of change

  • New feature
  • Bug fix
  • Optimization

Checklist

  • Linked to Github Issue:
  • Unit tests added
  • This change requires new documentation.
    • Documentation has been added/updated.
  • This change is an Optimization
    • Benchmarks added/run

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.

bug: groth16 circom-adapter incorrect public signals
1 participant