Circuitcompiler

package
v0.0.0-...-031a8c5 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2021 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EOFRune rune = -1
)

Variables

View Source
var Types = BOOL | U8 | U16 | U32 | U64 | FIELD

Functions

func ArrayString

func ArrayString(dimension []int64) string

func ArrayStringBuild

func ArrayStringBuild(in []int64, res string, coll *[]string)

outdated.. delete soon

func CalculateTrace

func CalculateTrace(r1cs *R1CS, input []InputArgument) (witness []*big.Int, err error)

func NewCircuit

func NewCircuit(name string, context *function) *function

Types

type Client

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

Client is a middleman between the websocket connection and the hub.

type Gate

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

func (*Gate) ID

func (gate *Gate) ID() (id string)

func (Gate) String

func (g Gate) String() string

type Hub

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

Hub maintains the set of active clients and broadcasts messages to the clients.

func StartServer

func StartServer(addr *string) *Hub

type InputArgument

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

func CombineInputs

func CombineInputs(abstract []string, concrete []*big.Int) (res []InputArgument)

func (InputArgument) String

func (in InputArgument) String() string

type Lexer

type Lexer struct {
	Err error

	ErrorHandler func(e string)
	// contains filtered or unexported fields
}

func New

func New(src string, start StateFunc) *Lexer

New creates a returns a lexer ready to parse the given source code.

func (*Lexer) Current

func (l *Lexer) Current() string

Current returns the value being being analyzed at this moment.

func (*Lexer) Emit

func (l *Lexer) Emit(t TokenType)

Emit will receive a token type and push a new token with the current analyzed value into the tokens channel.

func (*Lexer) Error

func (l *Lexer) Error(e string)

func (*Lexer) Ignore

func (l *Lexer) Ignore()

Ignore clears the rewind stack and then sets the current beginning position to the current position in the source which effectively ignores the section of the source being analyzed.

func (*Lexer) Next

func (l *Lexer) Next() rune

Next pulls the next rune from the Lexer and returns it, moving the position forward in the source.

func (*Lexer) NextToken

func (l *Lexer) NextToken() (*Token, bool)

nextToken returns the next token from the lexer and a value to denote whether or not the token is finished.

func (*Lexer) Peek

func (l *Lexer) Peek() rune

Peek performs a Next operation immediately followed by a Rewind returning the peeked rune.

func (*Lexer) PeekTwo

func (l *Lexer) PeekTwo() string

Peek performs a Next operation immediately followed by a Rewind returning the peeked rune.

func (*Lexer) Rewind

func (l *Lexer) Rewind()

Rewind will take the last rune read (if any) and rewind back. Rewinds can occur more than once per call to Next but you can never rewind past the last point a token was emitted.

func (*Lexer) Start

func (l *Lexer) Start()

Start begins executing the Lexer in an asynchronous manner (using a goroutine).

func (*Lexer) StartSync

func (l *Lexer) StartSync()

func (*Lexer) Take

func (l *Lexer) Take(chars string)

Take receives a string containing all acceptable strings and will contine over each consecutive character in the source until a token not in the given string is encountered. This should be used to quickly pull token parts.

type MultiplicationGateSignature

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

type Parser

type Parser struct {
	ErrorHandler func(e string)
	Err          error
	// contains filtered or unexported fields
}

func NewParser

func NewParser(code string, log bool) (p *Parser)

func (*Parser) Assert

func (p *Parser) Assert(in string, tok Token)

func (*Parser) AssertIdentifiedType

func (p *Parser) AssertIdentifiedType(typ TokenType, tok Token)

func (*Parser) AssertIdentifier

func (p *Parser) AssertIdentifier(token Token)

func (*Parser) AssertTypes

func (p *Parser) AssertTypes(toks []Token, types ...TokenType)

func (*Parser) PreCompile

func (p *Parser) PreCompile(currentCircuit *function, tokens []Token)

func (*Parser) PrepareFunctionSignature

func (p *Parser) PrepareFunctionSignature(newFunction *function, stack []Token)

type Program

type Program struct {
	PublicInputs []string
	// contains filtered or unexported fields
}

func Parse

func Parse(code string) (p *Program)

func (*Program) Execute

func (p *Program) Execute() (orderedmGates *gateContainer)

Execute runs on a program and returns a precursor for the final R1CS description

func (*Program) GatesToR1CS

func (p *Program) GatesToR1CS(mGates []*Gate) (r1CS *R1CS)

GenerateR1CS generates the R1CS Language from an array of gates

func (*Program) GetMainCircuit

func (p *Program) GetMainCircuit() *function

func (*Program) GlobalInputCount

func (p *Program) GlobalInputCount() int

returns the cardinality of all public inputs (+ 1 for the "one" signal)

type R1CS

type R1CS struct {
	WitnessLength, NumberOfGates int

	L []utils.Poly
	R []utils.Poly
	O []utils.Poly
	// contains filtered or unexported fields
}

func (*R1CS) Transpose

func (er1cs *R1CS) Transpose() (transposed *R1CSTransposed)

type R1CSSparse

type R1CSSparse struct {
	WitnessLength, NumberOfGates int
	L                            []*utils.AvlTree
	R                            []*utils.AvlTree
	O                            []*utils.AvlTree
	// contains filtered or unexported fields
}

func (*R1CSSparse) TransposeSparse

func (er1cs *R1CSSparse) TransposeSparse() (transposed *R1CSsPARSETransposed)

type R1CSTransposed

type R1CSTransposed struct {
	WitnessLength, NumberOfGates int
	L                            []utils.Poly
	R                            []utils.Poly
	O                            []utils.Poly
	// contains filtered or unexported fields
}

func (*R1CSTransposed) R1CSToEAP_FFT

func (er1cs *R1CSTransposed) R1CSToEAP_FFT(fft *utils.FFT_PrecomputedParas, pf *utils.PolynomialField, tau *big.Int) (Ai_Tau, Ri_Tau, Oi_Tau []*big.Int)

type R1CSsPARSETransposed

type R1CSsPARSETransposed struct {
	WitnessLength, NumberOfGates int
	L                            []*utils.AvlTree
	R                            []*utils.AvlTree
	O                            []*utils.AvlTree
	// contains filtered or unexported fields
}

type StateFunc

type StateFunc func(*Lexer) StateFunc

func DecimalNumberState

func DecimalNumberState(l *Lexer) StateFunc

func HexNumberState

func HexNumberState(l *Lexer) StateFunc

func IdentState

func IdentState(l *Lexer) StateFunc

func ProbablyWhitespaceState

func ProbablyWhitespaceState(l *Lexer) StateFunc

func WhitespaceState

func WhitespaceState(l *Lexer) StateFunc

type Task

type Task struct {
	Description Token
	Inputs      []*Task
	FktInputs   []*function
}

Task is the data structure of a flat code operation

func (*Task) Set

func (c *Task) Set(in Token) *Task

func (Task) String

func (c Task) String() string

type Token

type Token struct {
	Type       TokenType
	Identifier string
	// contains filtered or unexported fields
}

func (Token) CopyAndSetMultiplicative

func (f Token) CopyAndSetMultiplicative(v *big.Int) (n Token)

func (Token) Negate

func (f Token) Negate() (n Token)

func (Token) String

func (ch Token) String() string

type TokenType

type TokenType int
const (
	DecimalNumberToken TokenType = 1 << iota
	HexNumberToken
	SyntaxToken
	CommentToken
	AssignmentOperatorToken
	ArithmeticOperatorToken
	BooleanOperatorToken
	BitOperatorToken
	BinaryComperatorToken
	//UnaryOperatorToken
	EOF
	IMPORT
	PUBLIC
	IDENTIFIER_VARIABLE
	FUNCTION_DEFINE
	FUNCTION_CALL
	IF_FUNCTION_CALL
	VARIABLE_DECLARE
	VARIABLE_OVERLOAD
	ARRAY_DECLARE
	ARRAY_CALL
	UNASIGNEDVAR
	ARGUMENT
	IF
	ELSE
	FOR
	RETURN
	FIELD
	BOOL
	U8
	U16
	U32
	U64
	True
	False
)

func (TokenType) String

func (ch TokenType) String() string

type Tokens

type Tokens []Token

func (*Tokens) Add

func (in *Tokens) Add(a Token)

adds two Tokens to one iff they are both are constants or of the same variable

func (Tokens) AddFactors

func (this Tokens) AddFactors(with Tokens) Tokens

returns the reduced sum of two input factor arrays if no reduction was done, it returns the concatenation of the input arrays

func (Tokens) Len

func (f Tokens) Len() int

func (Tokens) Less

func (f Tokens) Less(i, j int) bool

func (Tokens) Negate

func (f Tokens) Negate() (n Tokens)

func (Tokens) Swap

func (f Tokens) Swap(i, j int)

Jump to

Keyboard shortcuts

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