-
Notifications
You must be signed in to change notification settings - Fork 493
Description
Description
Gnark allows for custom builders, allowing to build a constraint system without a circuit structure.
This inherits the frontend.API interface, allowing one to call deferred constraints such as with the lookup table interface.
Expected Behavior
When we call builder.Compile() we should construct the deferred constraints. Just like the Compile() function does for stnadard circuit construction. So if we constract a binary API, the constraints do not appear in the compiled constraint system.
Actual Behavior
All constraints attempted by the builder should be compiled in the constraint system.
Possible Fix
In the Compile function fo the r1cs and scs custom builders, we should call the equivalent of the callDeferred() function of the circuit Compile() function.
Steps to Reproduce
- Construct a new builder as follows
builder, err := r1cs.NewBuilder[E](ecc.BN254.ScalarField(), frontend.CompileConfig{ CompressThreshold: 300, }) - Construct a binary field api as follows
uapi, err := uints.New[uints.U64](builder) - Now
uapi.AssertEq(uints.NewU64(0), uints.NewU64(1))will not fail, because the constraints are never called
Context
Attempting to write a custom gnark circuit without having to use the circuit struct as above.
Your Environment
- gnark version used 0.14.0
- gnark-crypto version used: 0.19.0
- go version (e.g. 1.20.6): go1.24.4 darwin/arm64
- Operating System and version: macOS Sequoia 15.6.1