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

Method Or

ecgo/builder/api.go:240–261  ·  view source on GitHub ↗

Or computes the logical OR between two frontend.Variables.

(_a, _b frontend.Variable)

Source from the content-addressed store, hash-verified

238
239// Or computes the logical OR between two frontend.Variables.
240func (builder *builder) Or(_a, _b frontend.Variable) frontend.Variable {
241 vars := builder.toVariableIds(_a, _b)
242 a := vars[0]
243 b := vars[1]
244 c1, ok1 := builder.constantValue(a)
245 c2, ok2 := builder.constantValue(b)
246 if ok1 && ok2 {
247 builder.AssertIsBoolean(_a)
248 builder.AssertIsBoolean(_b)
249 if c1.IsZero() && c2.IsZero() {
250 return builder.toVariable(constraint.Element{})
251 }
252 return builder.toVariable(builder.tOne)
253 }
254 builder.instructions = append(builder.instructions, irsource.Instruction{
255 Type: irsource.BoolBinOp,
256 X: a,
257 Y: b,
258 ExtraId: 2,
259 })
260 return builder.addVar()
261}
262
263// And computes the logical AND between two frontend.Variables.
264func (builder *builder) And(_a, _b frontend.Variable) frontend.Variable {

Callers

nothing calls this directly

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