Documentation ¶
Overview ¶
Package circuit implements arithmetic circuits.
Index ¶
- Constants
- Variables
- type Circuit
- func (c *Circuit) AddGate(g *Gate)
- func (c *Circuit) AddZeroGate(g *Gate)
- func (c *Circuit) Eval(inputs []*big.Int) bool
- func (c *Circuit) ImportWires(prg *share.ReplayPRG)
- func (c *Circuit) InputGates() []*Gate
- func (c *Circuit) Modulus() *big.Int
- func (c *Circuit) MulGates() []*Gate
- func (c *Circuit) OutputName(i int) string
- func (c *Circuit) OutputNames() []string
- func (c *Circuit) Outputs() []*Gate
- func (c *Circuit) ShareWires(prg *share.GenPRG)
- func (c *Circuit) ShouldBeZero() []*Gate
- type Gate
Constants ¶
const ( Gate_Input = iota Gate_Add = iota Gate_AddConst = iota Gate_Mul = iota Gate_MulConst = iota )
Supported gate types.
Variables ¶
var NegOne *big.Int
Global constant set to -1 in the field.
Functions ¶
This section is empty.
Types ¶
type Circuit ¶
type Circuit struct {
// contains filtered or unexported fields
}
Circuit represents an arithmetic circuit over a particular finite field (specified by the modulus mod). The gates listed in shouldBeZero should all zero on their output wires iff the circuit accepts an input.
func AndCircuits ¶
func NBits ¶
A circuit that takes N inputs x1, ..., xN, which should all be 0/1 values in F.
The circuit first computes y_i = (x_i)*(x_i - 1) and requires that all y_i's are zero.
The output of the circuit is the sum:
\sum_i (2^i * x_i)
func OneBit ¶
A circuit that takes a single input x and computes
x*(x-1).
If x represents a 0/1 value in F, then this circuit outputs zero.
func (*Circuit) AddZeroGate ¶
func (*Circuit) Eval ¶
Evaluate a circuit on the given input values. Return true iff the circuit accepts the input.
func (*Circuit) ImportWires ¶
Import shared wire values from a ReplayPRG.
func (*Circuit) InputGates ¶
func (*Circuit) OutputName ¶
func (*Circuit) OutputNames ¶
func (*Circuit) ShareWires ¶
Split the wire values into shares.
func (*Circuit) ShouldBeZero ¶
type Gate ¶
Gate represents a gate in an arithmetic circuit, and possibly holds the value on its output wire.
On inputs x and y, each bilinear gate computes output z, where
z = (A x + B)(A' y + B').
If both parents are nil, it's an input gate.