Documentation
¶
Overview ¶
Package layered defines the structures and functions necessary for creating and manipulating layered circuits within the ExpanderCompilerCollection compiler. A layered circuit is a representation of a computation that is divided into a sequence of discrete layers, facilitating certain types of optimizations and parallel computations.
Index ¶
Constants ¶
const MAGIC = 3914834606642317635
Variables ¶
This section is empty.
Functions ¶
func DetectFieldIdFromFile ¶
Types ¶
type Allocation ¶
Allocation defines the input and output offsets for a subcircuit call. These offsets determine where the subcircuit's inputs and outputs are positioned within the larger circuit context.
type Circuit ¶
type Circuit struct { InputLen uint64 OutputLen uint64 SubCircuits []SubCircuit Mul []GateMul Add []GateAdd Cst []GateCst Custom []GateCustom }
Circuit represents a single segment within a layered circuit. It contains the length of inputs and outputs, a list of subcircuits that can be called within this segment, and the gates that perform various arithmetic operations within the segment.
type GateAdd ¶
GateAdd represents an addition gate within a circuit layer. It specifies the input and output wire indices, and the coefficient to be multiplied with the input before being added to the output.
type GateCst ¶
GateCst represents a constant gate within a circuit layer. It directly adds a constant value, defined by Coef, to the output wire.
type GateCustom ¶
type GateCustom struct { GateType uint64 In []uint64 Out uint64 Coef *big.Int CoefType uint8 PublicInputId uint64 }
GateCustom represents a custom gate within a circuit layer. It takes several inputs, and produces an output value. The output wire must be dedicated to this gate.
func (GateCustom) CoefValue ¶
func (g GateCustom) CoefValue() *big.Int
Coefficient value of customized gate
type GateMul ¶
type GateMul struct { In0 uint64 In1 uint64 Out uint64 Coef *big.Int CoefType uint8 PublicInputId uint64 }
GateMul represents a multiplication gate within a circuit layer. It specifies two input wire indices and an output wire index, along with a coefficient. The product of the inputs and the coefficient is added to the output.
type RootCircuit ¶
type RootCircuit struct { NumPublicInputs int NumActualOutputs int ExpectedNumOutputZeroes int Circuits []*Circuit Layers []uint64 Field *big.Int }
RootCircuit defines a multi-layered circuit. The Layers field specifies the indices of each layer, which are referenced through the Circuits array. Field denotes the mathematical field over which the circuit operations are carried out.
func DeserializeRootCircuit ¶
func DeserializeRootCircuit(buf []byte) *RootCircuit
func (*RootCircuit) Graphviz ¶
func (rc *RootCircuit) Graphviz() string
generate graphviz compatible DOT file for visualizing the circuit layout
func (*RootCircuit) Print ¶
func (rc *RootCircuit) Print()
Print outputs the entire multi-layered circuit structure to the console for debugging purposes. It provides a detailed view of the circuit's construction, including all gates and their connections across layers.
func (*RootCircuit) Serialize ¶
func (rc *RootCircuit) Serialize() []byte
Serialize converts a RootCircuit into a byte array for storage or transmission.
type SubCircuit ¶
type SubCircuit struct { Id uint64 Allocations []Allocation }
SubCircuit represents a subcircuit that is used within a Circuit. It has the identifier of the subcircuit (indexed in RootCircuit.Circuits) and a list of allocations that define the input and output connections to the subcircuit.