Conversation
reduce keeps a term whose merged coefficient is zero, so x + y - y records the addition x*1 + y*0. A later 2x + y - y finds that entry and tries to compute the output coefficient as q4/q2 = 0/0, which panics. Return "not found" there and add a new constraint instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Compiling this with the SCS builder fails with
parse circuit: div by 0, while R1CS and the test engine accept it:reducemergesBand-Binto a single term with coefficient 0, so the firstAddrecordsA*1 + B*0. The second one finds that entry inaddConstraintExist, theq3*q2 == q1*q4check passes as0 == 0, and thenInverse(q2)fails and hits thepanic("div by 0") // shouldn't happenbranch. #1068 fixed the same kind of zero coefficient forMul, but theAddpath can still get one through cancellation.The fix returns "not found" when
q2has no inverse, so the builder just adds a new constraint for this (rare) case. Nothing changes for circuits that compiled before.Tests:
TestExistDiv03fails on master withdiv by 0and passes with this change; the stats test shows no constraint count changes.