compiled

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CoeffIdZero     = 0
	CoeffIdOne      = 1
	CoeffIdTwo      = 2
	CoeffIdMinusOne = 3
)

ids of the coefficients with simple values in any cs.coeffs slice.

View Source
const R1CSTemplate = `` /* 1953-byte string literal not displayed */
View Source
const SparseR1CSTemplate = `` /* 2288-byte string literal not displayed */

Variables

This section is empty.

Functions

This section is empty.

Types

type CS added in v0.5.1

type CS struct {
	// number of wires
	NbInternalVariables int
	NbPublicVariables   int
	NbSecretVariables   int

	// logs (added with cs.Println, resolved when solver sets a value to a wire)
	Logs []LogEntry

	// debug info contains stack trace (including line number) of a call to a cs.API that
	// results in an unsolved constraint
	DebugInfo []LogEntry

	// maps wire id to hint
	// a wire may point to at most one hint
	MHints map[int]Hint

	// maps constraint id to debugInfo id
	// several constraints may point to the same debug info
	MDebug map[int]int
}

CS contains common element between R1CS and CS

func (*CS) CurveID added in v0.5.1

func (cs *CS) CurveID() ecc.ID

CurveID returns ecc.UNKNOWN

func (*CS) FrSize added in v0.5.1

func (cs *CS) FrSize() int

FrSize panics

func (*CS) GetNbCoefficients added in v0.5.1

func (cs *CS) GetNbCoefficients() int

GetNbCoefficients panics

func (*CS) GetNbVariables added in v0.5.1

func (cs *CS) GetNbVariables() (internal, secret, public int)

GetNbVariables return number of internal, secret and public variables

func (*CS) ReadFrom added in v0.5.1

func (cs *CS) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom panics

func (*CS) ToHTML added in v0.5.1

func (cs *CS) ToHTML(w io.Writer) error

ToHTML panics

func (*CS) WriteTo added in v0.5.1

func (cs *CS) WriteTo(w io.Writer) (n int64, err error)

WriteTo panics

type Hint added in v0.5.1

type Hint struct {
	ID     hint.ID            // hint function id
	Inputs []LinearExpression // terms to inject in the hint function
}

Hint represents a solver hint it enables the solver to compute a Wire with a function provided at solving time using pre-defined inputs

type LinearExpression

type LinearExpression []Term

LinearExpression represent a linear expression of variables

func (LinearExpression) Clone

Clone returns a copy of the underlying slice

func (LinearExpression) Len added in v0.5.0

func (l LinearExpression) Len() int

Len return the lenght of the LinearExpression (implements Sort interface)

func (LinearExpression) Less added in v0.5.0

func (l LinearExpression) Less(i, j int) bool

Less returns true if variableID for term at i is less than variableID for term at j (implements Sort interface)

func (LinearExpression) Swap added in v0.5.0

func (l LinearExpression) Swap(i, j int)

Swap swaps terms in the LinearExpression (implements Sort interface)

type LogEntry

type LogEntry struct {
	Format    string
	ToResolve []Term
}

LogEntry is used as a shared data structure between the frontend and the backend to represent string values (in logs or debug info) where a value is not known at compile time (which is the case for variables that need to be resolved in the R1CS)

func (*LogEntry) WriteLinearExpression added in v0.5.1

func (l *LogEntry) WriteLinearExpression(le LinearExpression, sbb *strings.Builder)

func (*LogEntry) WriteStack added in v0.5.1

func (l *LogEntry) WriteStack(sbb *strings.Builder)

func (*LogEntry) WriteTerm added in v0.5.1

func (l *LogEntry) WriteTerm(t Term, sbb *strings.Builder)

type R1C

type R1C struct {
	L, R, O LinearExpression
}

R1C used to compute the wires

func (*R1C) String added in v0.5.1

func (r1c *R1C) String(coeffs []big.Int) string

type R1CS

type R1CS struct {
	CS
	Constraints []R1C
}

R1CS decsribes a set of R1C constraint

func (*R1CS) GetNbConstraints

func (r1cs *R1CS) GetNbConstraints() int

GetNbConstraints returns the number of constraints

type SparseR1C

type SparseR1C struct {
	L, R, O Term
	M       [2]Term
	K       int // stores only the ID of the constant term that is used
}

SparseR1C used to compute the wires L+R+M[0]M[1]+O+k=0 if a Term is zero, it means the field doesn't exist (ex M=[0,0] means there is no multiplicative term)

func (*SparseR1C) String added in v0.5.1

func (r1c *SparseR1C) String(coeffs []big.Int) string

type SparseR1CS

type SparseR1CS struct {
	CS
	Constraints []SparseR1C
}

R1CS decsribes a set of SparseR1C constraint

func (*SparseR1CS) GetNbConstraints

func (cs *SparseR1CS) GetNbConstraints() int

GetNbConstraints returns the number of constraints

type Term

type Term uint64

Term lightweight version of a term, no pointers first 4 bits are reserved next 30 bits represented the coefficient idx (in r1cs.Coefficients) by which the wire is multiplied next 30 bits represent the constraint used to compute the wire if we support more than 1 billion constraints, this breaks (not so soon.)

const TermDelimitor Term = Term(maskDelimitor)

TermDelimitor is reserved for internal use the constraint solver will evaluate the sum of all terms appearing between two TermDelimitor

func Pack

func Pack(variableID, coeffID int, variableVisiblity Visibility) Term

Pack packs variableID, coeffID and coeffValue into Term first 5 bits are reserved to encode visibility of the constraint and coeffValue of the coefficient next 30 bits represented the coefficient idx (in r1cs.Coefficients) by which the wire is multiplied next 29 bits represent the constraint used to compute the wire if we support more than 500 millions constraints, this breaks (not so soon.)

func (Term) CoeffID

func (t Term) CoeffID() int

CoeffID returns the coefficient id (see R1CS data structure)

func (*Term) SetCoeffID

func (t *Term) SetCoeffID(cID int)

SetCoeffID update the bits correponding to the coeffID with cID

func (*Term) SetVariableID

func (t *Term) SetVariableID(cID int)

SetVariableID update the bits correponding to the variableID with cID

func (*Term) SetVariableVisibility

func (t *Term) SetVariableVisibility(v Visibility)

SetVariableVisibility update the bits correponding to the variableVisiblity with its encoding

func (Term) Unpack

func (t Term) Unpack() (coeffID, variableID int, variableVisiblity Visibility)

Unpack returns coeffID, variableID and visibility

func (Term) VariableID

func (t Term) VariableID() int

VariableID returns the variableID (see R1CS data structure)

func (Term) VariableVisibility

func (t Term) VariableVisibility() Visibility

VariableVisibility returns encoded Visibility attribute

type Visibility

type Visibility uint8

Visibility encodes a Variable (or wire) visibility Possible values are Unset, Internal, Secret or Public

const (
	Unset Visibility = iota
	Internal
	Secret
	Public
	Virtual
)

Jump to

Keyboard shortcuts

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