Skip to content

Commit

Permalink
perf: don't store stack for assert boolean if no debug flag
Browse files Browse the repository at this point in the history
  • Loading branch information
gbotrel committed Dec 20, 2022
1 parent 1204a89 commit f918071
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions frontend/cs/r1cs/api_assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package r1cs
import (
"math/big"

"github.com/consensys/gnark/debug"
"github.com/consensys/gnark/frontend"
"github.com/consensys/gnark/frontend/internal/expr"
"github.com/consensys/gnark/internal/utils"
Expand Down Expand Up @@ -64,9 +65,13 @@ func (builder *builder) AssertIsBoolean(i1 frontend.Variable) {
o := builder.cstZero()

V := builder.getLinearExpression(v)
debug := builder.newDebugInfo("assertIsBoolean", V, " == (0|1)")

builder.cs.AddConstraint(builder.newR1C(V, _v, o), debug)
if debug.Debug {
debug := builder.newDebugInfo("assertIsBoolean", V, " == (0|1)")
builder.cs.AddConstraint(builder.newR1C(V, _v, o), debug)
} else {
builder.cs.AddConstraint(builder.newR1C(V, _v, o))
}
}

// AssertIsLessOrEqual adds assertion in constraint builder (v ⩽ bound)
Expand Down

0 comments on commit f918071

Please sign in to comment.