I'll assume that these hard-coded constants are public (known to both garbler and evaluator). There are a few options:
Treat the constants as extra inputs to the circuit, like you suggest. Note that input wires can be reused for many gates, so you only need a single true
and false
wire for the entire circuit. Most garbling schemes support not
gates for free, so you actually only need a constant true
wire. Furthermore, it turns out that you can always take the true
wire label to be the string of all zeroes, without loss of generality. Combining all of these observations, the extra constant input wires add no cost to the circuit.
Propagate constants through the circuit. For example, a gate y=AND(x,true)
becomes just y=x
, meaning that you can replace the y
wire by x
in any downstream gates that use y
as an input. A gate y=AND(x,false)
becomes y=false
, and you can again propagate y=false
downstream in gates that use y
as an input. By doing this, you'll see that many gates downstream of the hard-coded constant can simply be removed entirely from the circuit. This process has nothing to do with garbling, but is just simplifying the boolean circuit based on hard-coded inputs.
If the constants are known only to the garbler, then the goal is to simplify the circuit/garbling while hiding those constants.
Most garbling schemes (and certainly the leading state of the art ones) support gates that absorb free not
gates, meaning that you can garble and(not(x),y)
, and(x,not(y))
, ... gates for the same cost as garbling an and
gate. In fact, these garbling schemes hide the existence of these not
gates. Using this observation, you can still do #1 from above. If you need to hard code a gate y=and(x,false)
then you can feed your single true
input wire into a gate of the form y=and(x,NOT(true))
while hiding the presence of that not
(i.e., hiding whether the gate was hard-coded with a true
or false
).
However, you can do slightly better by using the "garbler half-gate" from the half-gates construction. This lets you garble an and(x,true)
or and(x,false)
gate, while hiding which one is garbled, for half the cost of a full-fledged and
-gate.