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

Method And

ecgo/builder/api.go:264–285  ·  view source on GitHub ↗

And computes the logical AND between two frontend.Variables.

(_a, _b frontend.Variable)

Source from the content-addressed store, hash-verified

262
263// And computes the logical AND between two frontend.Variables.
264func (builder *builder) And(_a, _b frontend.Variable) frontend.Variable {
265 vars := builder.toVariableIds(_a, _b)
266 a := vars[0]
267 b := vars[1]
268 c1, ok1 := builder.constantValue(a)
269 c2, ok2 := builder.constantValue(b)
270 if ok1 && ok2 {
271 builder.AssertIsBoolean(_a)
272 builder.AssertIsBoolean(_b)
273 if c1.IsZero() || c2.IsZero() {
274 return builder.toVariable(constraint.Element{})
275 }
276 return builder.toVariable(builder.tOne)
277 }
278 builder.instructions = append(builder.instructions, irsource.Instruction{
279 Type: irsource.BoolBinOp,
280 X: a,
281 Y: b,
282 ExtraId: 3,
283 })
284 return builder.addVar()
285}
286
287// ---------------------------------------------------------------------------------------------
288// Conditionals

Callers 1

CmpMethod · 0.95

Calls 6

toVariableIdsMethod · 0.95
constantValueMethod · 0.95
AssertIsBooleanMethod · 0.95
toVariableMethod · 0.95
addVarMethod · 0.95
IsZeroMethod · 0.80

Tested by

no test coverage detected