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

Method Xor

ecgo/builder/api.go:215–237  ·  view source on GitHub ↗

Xor computes the logical XOR between two frontend.Variables.

(_a, _b frontend.Variable)

Source from the content-addressed store, hash-verified

213
214// Xor computes the logical XOR between two frontend.Variables.
215func (builder *builder) Xor(_a, _b frontend.Variable) frontend.Variable {
216 vars := builder.toVariableIds(_a, _b)
217 a := vars[0]
218 b := vars[1]
219 c1, ok1 := builder.constantValue(a)
220 c2, ok2 := builder.constantValue(b)
221 if ok1 && ok2 {
222 builder.AssertIsBoolean(_a)
223 builder.AssertIsBoolean(_b)
224 t := builder.field.Sub(c1, c2)
225 if t.IsZero() {
226 return builder.toVariable(constraint.Element{})
227 }
228 return builder.toVariable(builder.tOne)
229 }
230 builder.instructions = append(builder.instructions, irsource.Instruction{
231 Type: irsource.BoolBinOp,
232 X: a,
233 Y: b,
234 ExtraId: 1,
235 })
236 return builder.addVar()
237}
238
239// Or computes the logical OR between two frontend.Variables.
240func (builder *builder) Or(_a, _b frontend.Variable) frontend.Variable {

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected