Xor computes the logical XOR between two frontend.Variables.
(_a, _b frontend.Variable)
| 213 | |
| 214 | // Xor computes the logical XOR between two frontend.Variables. |
| 215 | func (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. |
| 240 | func (builder *builder) Or(_a, _b frontend.Variable) frontend.Variable { |
nothing calls this directly
no test coverage detected