Skip to content

Conversation

@gbotrel
Copy link
Collaborator

@gbotrel gbotrel commented Aug 11, 2022

used to have 3 constraints for api.IsZero

// m * (1 - m) = 0       // constrain m to be 0 or 1
// a * m = 0            // constrain m to be 0 if a != 0
// _ = inverse(m + a) 	// constrain m to be 1 if a == 0
// m is computed by the solver such that m = 1 - a^(modulus - 1)

can be done in 2:

// x = 1/a 		// in a hint (x == 0 if a == 0)
// m = -a*x + 1         // constrain m to be 1 if a == 0
// a * m = 0            // constrain m to be 0 if a != 0

@gbotrel gbotrel added this to the v0.8.0 milestone Aug 11, 2022
@gbotrel gbotrel requested a review from ThomasPiellard August 11, 2022 15:51
@gbotrel gbotrel marked this pull request as draft August 16, 2022 15:44
@gbotrel gbotrel marked this pull request as ready for review August 19, 2022 15:09
@gbotrel gbotrel merged commit b308ebb into develop Aug 19, 2022
@gbotrel gbotrel deleted the perf/iszero branch August 19, 2022 15:09
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