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

refactor: frontend.Variable is now an interface, simplifies witness assignment and constant usage #180

Merged
merged 13 commits into from
Nov 17, 2021

Conversation

gbotrel
Copy link
Collaborator

@gbotrel gbotrel commented Nov 17, 2021

This PR addresses few feedbacks.

It unfortunately introduces some breaking changes in the API.

  • circuit.Define(curveID, api) is now circuit.Define(api)
  • frontend.Variable is now an interface. Consequences to that is;
  • api.Constant(x) is removed, doing myVariable = 2 instead of myVariable = api.Constant(2) will behaves as expected.
  • Assign() method is removed, one can now simply assign witness value like so witness := &circuit{A: value}
  • added api.IsConstant(Variable) -> bool and api.ConstantValue(Variable) -> big.Int which enables circuit developers to write specific version of their circuit depending on if a variable is known at compile time. Note: the big.Int test engine will return true to all values, and may not test all code path against the constraint solver.

Unsuspected side effect to this PR; frontend.Compile is now ~40% faster for Groth16.

Copy link
Collaborator

@ivokub ivokub left a comment

Choose a reason for hiding this comment

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

Looks good in general. Added a few type descriptions and fixed some assignments.

frontend/frontend.go Outdated Show resolved Hide resolved
frontend/api.go Outdated Show resolved Hide resolved
frontend/circuit.go Outdated Show resolved Hide resolved
frontend/circuit.go Outdated Show resolved Hide resolved
frontend/cs_api.go Outdated Show resolved Hide resolved
std/signature/eddsa/eddsa_test.go Outdated Show resolved Hide resolved
std/signature/eddsa/eddsa_test.go Outdated Show resolved Hide resolved
std/signature/eddsa/eddsa_test.go Outdated Show resolved Hide resolved
std/signature/eddsa/eddsa_test.go Outdated Show resolved Hide resolved
std/signature/eddsa/eddsa_test.go Outdated Show resolved Hide resolved
gbotrel and others added 2 commits November 17, 2021 13:08
Co-authored-by: Ivo Kubjas <tsimmm@gmail.com>
Co-authored-by: Ivo Kubjas <tsimmm@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants