zkFold / zkfold-base

ZkFold's Base library
https://zkfold.io
MIT License
17 stars 7 forks source link

Optimize Arithmetic Circuits #324

Closed hovanja2011 closed 1 week ago

hovanja2011 commented 1 month ago

Now we are creating a NewVar variable in the circuits, even if it is a constant (function unconstrained). In addition, when adding constraints (function constraint), there is no check on whether the polynomial is a constant (equal to zero).

Using the trick of substituting a function in witness (see the toVar function), we can see how the function works from the inside. And separate the constant variables from the rest.

For example, you can separate constants using the method below:

witness $ \case
    SysVar (InVar inV) -> Nothing
    SysVar (NewVar newV) -> Nothing
    ConstVar cV -> Just cV
vlasin commented 4 weeks ago

Added a comment related to circuit optimization here: #270.