circuit

package
v0.0.0-...-81eada0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildCircuit

func BuildCircuit(c Circuit) error

BuildCircuit - Computes the Out layers - Ensures there is no input used more than once : multi-instances must be explicitly provided as intermediary layers

Types

type Assignment

type Assignment []poly.MultiLin

Assigment for a GKR circuit

func (Assignment) Dump

func (a Assignment) Dump()

InputLayersOf returns the input layers of the layer l

func (Assignment) InputsOfLayer

func (a Assignment) InputsOfLayer(c Circuit, l int) []poly.MultiLin

InputLayersOf returns the input layers of the layer l

type Circuit

type Circuit []Layer

func (Circuit) Assign

func (c Circuit) Assign(inps ...poly.MultiLin) (a Assignment)

Assign computes the full assignment

func (Circuit) InputArity

func (c Circuit) InputArity() int

Returns the input arity of the circuit

func (Circuit) IsInputLayer

func (c Circuit) IsInputLayer(layer int) bool

IsInputLayer returns true/false if this is an input layer There are multiple ways of checking a layer is an input or output All of them are checked. This helps as a sanity checks : it will panic if any of the checks contradict the others.

type Gate

type Gate interface {
	// ID returns an ID that is unique for the gate
	ID() string
	// GnarkEval performs the same computation as Eval but on Gnark variables
	GnarkEval(cs frontend.API, xs ...frontend.Variable) frontend.Variable
	// EvalBatch returns an evaluation for a range of inputs passed in evals
	// And puts each result in res
	EvalBatch(res []fr.Element, xs ...[]fr.Element)
	// Eval returns an evaluation for a unique pair of Eval
	Eval(res *fr.Element, xs ...*fr.Element)
	// Degree returns the degrees of the gate relatively to HPrime
	Degree() (degHPrime int)
}

Gate assumes the gate can only have 2 inputs

type Layer

type Layer struct {
	// Variables indexes that are inputs to compute the current variable
	// Empty, means this an input layer
	In []int
	// Variables indexes that are fed by the current variable
	// Empty means this is an output layer
	Out []int
	// Expresses how to build the variable
	Gate Gate
}

Variable describes a circuit variable

func (*Layer) Evaluate

func (l *Layer) Evaluate(inputs ...[]fr.Element) []fr.Element

Evaluate returns the assignment of the next layer It can be multi-threaded

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL