MCPcopy Create free account
hub / github.com/PolyhedraZK/ExpanderCompilerCollection / IsZero

Method IsZero

ecgo/builder/api.go:342–355  ·  view source on GitHub ↗

IsZero returns 1 if the given variable is zero, otherwise returns 0.

(i1 frontend.Variable)

Source from the content-addressed store, hash-verified

340
341// IsZero returns 1 if the given variable is zero, otherwise returns 0.
342func (builder *builder) IsZero(i1 frontend.Variable) frontend.Variable {
343 a := builder.toVariableId(i1)
344 if c, ok := builder.constantValue(a); ok {
345 if c.IsZero() {
346 return builder.toVariable(builder.tOne)
347 }
348 return builder.toVariable(constraint.Element{})
349 }
350 builder.instructions = append(builder.instructions, irsource.Instruction{
351 Type: irsource.IsZero,
352 X: a,
353 })
354 return builder.addVar()
355}
356
357// Cmp compares i1 and i2 and returns 1 if i1>i2, 0 if i1=i2, -1 if i1<i2.
358func (builder *builder) Cmp(i1, i2 frontend.Variable) frontend.Variable {

Callers 11

CmpMethod · 0.95
DivUncheckedMethod · 0.80
DivMethod · 0.80
XorMethod · 0.80
OrMethod · 0.80
AndMethod · 0.80
SelectMethod · 0.80
AssertIsEqualMethod · 0.80
AssertIsDifferentMethod · 0.80
AssertIsBooleanMethod · 0.80
InverseMethod · 0.80

Calls 4

toVariableIdMethod · 0.95
constantValueMethod · 0.95
toVariableMethod · 0.95
addVarMethod · 0.95

Tested by

no test coverage detected