dusk-network / plonk

Pure Rust implementation of the PLONK ZKProof System done by the Dusk team
https://dusk-network.github.io/plonk
Mozilla Public License 2.0
535 stars 148 forks source link

Negative_one is recomputed inefficiently #798

Closed moCello closed 8 months ago

moCello commented 8 months ago

Summary

The repository stores “one” as a constant, but every time we need a negative one, it is recomputed using the relatively expensive neg() function. Negative one is used in several important functions such as assert_equal(), assert_equal_constant(), component_boolean(), and a few other places. Because it is used relatively frequently, it may be worth storing it once rather than recomputing it every time.

Recommendation: consider whether it’s worth storing negative_one as a constant to increase performance.

Relevant Context

Performance improvement recommendation from the audit.

moCello commented 8 months ago

Even though this seems like a plausible way of improving the performance, it actually neither improves the proving nor the verification time.

We might see an increase in performance in the circuit composition but since we store the circuit description (the values of the circuit after it has been composed), a change to a constant BlsScalar -1 doesn't lead to an increase in performance.

moCello commented 8 months ago

This will not increase performance in proving or verification times.