arkworks-rs / r1cs-std

R1CS constraints for bits, fields, and elliptic curves
https://www.arkworks.rs
Apache License 2.0
133 stars 58 forks source link

`FpVar::{is_eq, is_neq}` only need two constraints #133

Closed winderica closed 8 months ago

winderica commented 9 months ago

Description

Hi there, thanks for your amazing work!

This PR reduces 1 constraint in FpVar::{is_eq, is_neq} (and in turn, is_zero, etc.), by observing that we can remove the booleanity check while preserving soundness.

This is because:

See also gnark's implementation: https://github.com/Consensys/gnark/blob/870ef4efa8c9fa11a8778821c8376286207ca19b/frontend/cs/r1cs/api.go#L535-L569

Please correct me if I misunderstood something :)


Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why.