circuitcompiler

package
v0.0.0-...-735e08d Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Circuit

type Circuit struct {
	NVars         int
	NPublic       int
	NSignals      int
	PrivateInputs []string
	PublicInputs  []string
	Signals       []string
	Witness       []*big.Int
	Constraints   []Constraint
	R1CS          struct {
		A [][]*big.Int
		B [][]*big.Int
		C [][]*big.Int
	}
}

Circuit is the data structure of the compiled circuit

func (*Circuit) CalculateWitness

func (circ *Circuit) CalculateWitness(privateInputs []*big.Int, publicInputs []*big.Int) ([]*big.Int, error)

CalculateWitness calculates the Witness of a Circuit based on the given inputs witness = [ one, output, publicInputs, privateInputs, ...]

func (*Circuit) GenerateR1CS

func (circ *Circuit) GenerateR1CS() ([][]*big.Int, [][]*big.Int, [][]*big.Int)

GenerateR1CS generates the R1CS polynomials from the Circuit

type Constraint

type Constraint struct {
	// v1 op v2 = out
	Op      string
	V1      string
	V2      string
	Out     string
	Literal string

	PrivateInputs []string // in func declaration case
	PublicInputs  []string // in func declaration case
}

Constraint is the data structure of a flat code operation

type Inputs

type Inputs struct {
	Private []*big.Int
	Public  []*big.Int
}

type OperatorSymbol

type OperatorSymbol int

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser data structure holds the Scanner and the Parsing functions

func NewParser

func NewParser(r io.Reader) *Parser

NewParser creates a new parser from a io.Reader

func (*Parser) Parse

func (p *Parser) Parse() (*Circuit, error)

Parse parses the lines and returns the compiled Circuit

type Scanner

type Scanner struct {
	// contains filtered or unexported fields
}

Scanner holds the bufio.Reader

func NewScanner

func NewScanner(r io.Reader) *Scanner

NewScanner creates a new Scanner with the given io.Reader

type Token

type Token int
const (
	ILLEGAL Token = iota
	WS
	EOF

	IDENT // val

	VAR   // var
	CONST // const value

	EQ       // =
	PLUS     // +
	MINUS    // -
	MULTIPLY // *
	DIVIDE   // /
	EXP      // ^

	OUT
)

Jump to

Keyboard shortcuts

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