vfhe.circuit

vfhe.circuit: layered GKR arithmetic circuits.

  • builder: construct and (de)serialize circuits over the protobuf wire format (re-exported here).

  • export: evaluate circuits and export their MLE tables / wiring predicates as vfhe.arith polynomials for the SNARK layers (imported explicitly; it is the only part that touches arith).

vfhe.circuit.add_gate(left: int, right: int) → Gate

A fan-in-2 ADD gate wiring two inputs from the previous layer.

vfhe.circuit.deserialize(data: bytes) → Circuit

Parse a GKR circuit from its protobuf wire format.

vfhe.circuit.mul_gate(left: int, right: int) → Gate

A fan-in-2 MUL gate wiring two inputs from the previous layer.

vfhe.circuit.serialize(circuit: Circuit) → bytes

Serialize a GKR circuit to its protobuf wire format.

vfhe.circuit.xmult_gate(lefts: list[int], rights: list[int]) → Gate

An inner-product gate: sum_i in[lefts[i]] * in[rights[i]] over the previous layer (a MUL gate is the one-pair case).