extractor

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

This file contains the public API for running the extractor.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CircuitToLean

func CircuitToLean(circuit frontend.Circuit, field ecc.ID) (string, error)

CircuitToLean exports a `circuit` to Lean over a `field` with the namespace being the struct name of `circuit` When the namespace argument is not defined, it uses the name of the struct circuit

func CircuitToLeanWithName

func CircuitToLeanWithName(circuit frontend.Circuit, field ecc.ID, namespace string) (out string, err error)

CircuitToLeanWithName exports a `circuit` to Lean over a `field` with `namespace` CircuitToLeanWithName and CircuitToLean aren't joined in a single function CircuitToLean(circuit abstractor.Circuit, field ecc.ID, namespace ...string) because the long term view is to add an optional parameter to support custom `set_option` directives in the header.

func ExtractCircuits

func ExtractCircuits(namespace string, field ecc.ID, circuits ...frontend.Circuit) (out string, err error)

ExtractCircuits is used to export a series of `circuits` to Lean over a `field` under `namespace`.

func ExtractGadgets

func ExtractGadgets(namespace string, field ecc.ID, gadgets ...abstractor.GadgetDefinition) (out string, err error)

ExtractGadgets is used to export a series of `gadgets` to Lean over a `field` under `namespace`.

func GadgetToLean

func GadgetToLean(gadget abstractor.GadgetDefinition, field ecc.ID) (string, error)

GadgetToLean exports a `gadget` to Lean over a `field`

func GadgetToLeanWithName

func GadgetToLeanWithName(gadget abstractor.GadgetDefinition, field ecc.ID, namespace string) (out string, err error)

GadgetToLeanWithName exports a `gadget` to Lean over a `field` with `namespace` Same notes written for CircuitToLeanWithName apply to GadgetToLeanWithName and GadgetToLean

Types

type App

type App struct {
	Op   Op
	Args []Operand
}

type Code

type Code struct {
	Gates []App
}

type CodeExtractor

type CodeExtractor struct {
	Code    []App
	Gadgets []ExGadget
	FieldID ecc.ID
}

func (*CodeExtractor) Add

func (*CodeExtractor) AddApp

func (ce *CodeExtractor) AddApp(op Op, args ...frontend.Variable) Operand

func (*CodeExtractor) And

func (*CodeExtractor) AssertIsBoolean

func (ce *CodeExtractor) AssertIsBoolean(i1 frontend.Variable)

func (*CodeExtractor) AssertIsDifferent

func (ce *CodeExtractor) AssertIsDifferent(i1, i2 frontend.Variable)

func (*CodeExtractor) AssertIsEqual

func (ce *CodeExtractor) AssertIsEqual(i1, i2 frontend.Variable)

func (*CodeExtractor) AssertIsLessOrEqual

func (ce *CodeExtractor) AssertIsLessOrEqual(v frontend.Variable, bound frontend.Variable)

func (*CodeExtractor) Call

func (ce *CodeExtractor) Call(gadget abstractor.GadgetDefinition) interface{}

func (*CodeExtractor) Cmp

func (*CodeExtractor) Commit

func (*CodeExtractor) Compiler

func (ce *CodeExtractor) Compiler() frontend.Compiler

func (*CodeExtractor) ConstantValue

func (ce *CodeExtractor) ConstantValue(v frontend.Variable) (*big.Int, bool)

func (*CodeExtractor) DefineGadget

func (ce *CodeExtractor) DefineGadget(gadget abstractor.GadgetDefinition) abstractor.Gadget

func (*CodeExtractor) Div

func (*CodeExtractor) DivUnchecked

func (ce *CodeExtractor) DivUnchecked(i1, i2 frontend.Variable) frontend.Variable

func (*CodeExtractor) Field

func (ce *CodeExtractor) Field() *big.Int

func (*CodeExtractor) FieldBitLen

func (ce *CodeExtractor) FieldBitLen() int

func (*CodeExtractor) FromBinary

func (ce *CodeExtractor) FromBinary(b ...frontend.Variable) frontend.Variable

func (*CodeExtractor) Inverse

func (*CodeExtractor) IsBoolean

func (ce *CodeExtractor) IsBoolean(v frontend.Variable) bool

func (*CodeExtractor) IsZero

func (*CodeExtractor) Lookup2

func (ce *CodeExtractor) Lookup2(b0, b1 frontend.Variable, i0, i1, i2, i3 frontend.Variable) frontend.Variable

func (*CodeExtractor) MarkBoolean

func (ce *CodeExtractor) MarkBoolean(v frontend.Variable)

func (*CodeExtractor) Mul

func (*CodeExtractor) MulAcc

func (ce *CodeExtractor) MulAcc(a, b, c frontend.Variable) frontend.Variable

func (*CodeExtractor) Neg

func (*CodeExtractor) NewHint

func (ce *CodeExtractor) NewHint(f hint.Function, nbOutputs int, inputs ...frontend.Variable) ([]frontend.Variable, error)

func (*CodeExtractor) Or

func (*CodeExtractor) Println

func (ce *CodeExtractor) Println(a ...frontend.Variable)

func (*CodeExtractor) Select

func (*CodeExtractor) Sub

func (*CodeExtractor) ToBinary

func (ce *CodeExtractor) ToBinary(i1 frontend.Variable, n ...int) []frontend.Variable

func (*CodeExtractor) Xor

type Const

type Const struct {
	Value *big.Int
}

type ExArg

type ExArg struct {
	Name string
	Kind reflect.Kind
	Type ExArgType
}

type ExArgType

type ExArgType struct {
	Size int
	Type *ExArgType
}

type ExCircuit

type ExCircuit struct {
	Inputs  []ExArg
	Gadgets []ExGadget
	Code    []App
	Field   ecc.ID
}

type ExGadget

type ExGadget struct {
	Name        string
	Arity       int
	Code        []App
	OutputsFlat []Operand
	Outputs     interface{}
	Extractor   *CodeExtractor
	Fields      []schema.Field
	Args        []ExArg
}

func (*ExGadget) Call

func (g *ExGadget) Call(gadget abstractor.GadgetDefinition) interface{}

type Gate

type Gate struct {
	Index int
}

type Input

type Input struct {
	Index int
}

Input is used to save the position of the argument in the list of arguments of the circuit function.

type Integer

type Integer struct {
	Value *big.Int
}

Integer struct is used to distinguish between a constant in place of a frontend.Variable and an integer where an integer is the only type allowed. Integer sruct is currently only used for the length of the result in ToBinary function.

type Op

type Op interface {
	// contains filtered or unexported methods
}

type OpKind

type OpKind int
const (
	OpAdd OpKind = iota
	OpMulAcc
	OpNegative
	OpSub
	OpMul
	OpDiv
	OpDivUnchecked
	OpInverse
	OpToBinary
	OpFromBinary
	OpXor
	OpOr
	OpAnd
	OpSelect
	OpLookup
	OpIsZero
	OpCmp
	OpAssertEq
	OpAssertNotEq
	OpAssertIsBool
	OpAssertLessEqual
)

type Operand

type Operand interface {
	// contains filtered or unexported methods
}

type Proj

type Proj struct {
	Operand Operand
	Index   int
	Size    int
}

Index is the index to be accessed in the array Operand[Index] Size is a placeholder to keep track of the whole array size. It is essential to know if the whole vector or only a slice is used as function argument.

type ProjArray

type ProjArray struct {
	Projs []Operand
}

Jump to

Keyboard shortcuts

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