Documentation ¶
Index ¶
- Constants
- type ConstraintSystem
- func (cs *ConstraintSystem) AddDebugInfo(errName string, i ...interface{}) int
- func (cs *ConstraintSystem) BitLen() int
- func (cs *ConstraintSystem) Curve() ecc.ID
- func (cs *ConstraintSystem) GetCounters() []Counter
- func (cs *ConstraintSystem) GetNbVariables() (internal, secret, public int)
- func (cs *ConstraintSystem) GetSchema() *schema.Schema
- type Counter
- type Hint
- type LinearExpression
- type LogEntry
- type R1C
- type R1CS
- type SparseR1C
- type SparseR1CS
- type Term
- func (t Term) CoeffID() int
- func (t *Term) SetCoeffID(cID int)
- func (t *Term) SetVariableVisibility(v schema.Visibility)
- func (t *Term) SetWireID(cID int)
- func (t Term) Unpack() (coeffID, variableID int, variableVisiblity schema.Visibility)
- func (t Term) VariableVisibility() schema.Visibility
- func (t Term) WireID() int
Constants ¶
const ( CoeffIdZero = 0 CoeffIdOne = 1 CoeffIdTwo = 2 CoeffIdMinusOne = 3 )
ids of the coefficients with simple values in any cs.coeffs slice.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConstraintSystem ¶
type ConstraintSystem struct { // schema of the circuit Schema *schema.Schema // number of wires NbInternalVariables int NbPublicVariables int NbSecretVariables int // input wires names Public, Secret []string // 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 constraint id to debugInfo id // several constraints may point to the same debug info MDebug map[int]int Counters []Counter // TODO @gbotrel no point in serializing these MHints map[int]*Hint // maps wireID to hint MHintsDependencies map[hint.ID]string // maps hintID to hint string identifier // each level contains independent constraints and can be parallelized // it is guaranteed that all dependncies for constraints in a level l are solved // in previous levels Levels [][]int CurveID ecc.ID }
ConstraintSystem contains common element between R1CS and ConstraintSystem
func (*ConstraintSystem) AddDebugInfo ¶
func (cs *ConstraintSystem) AddDebugInfo(errName string, i ...interface{}) int
func (*ConstraintSystem) BitLen ¶
func (cs *ConstraintSystem) BitLen() int
bitLen returns the number of bits needed to represent a fr.Element
func (*ConstraintSystem) Curve ¶
func (cs *ConstraintSystem) Curve() ecc.ID
func (*ConstraintSystem) GetCounters ¶
func (cs *ConstraintSystem) GetCounters() []Counter
GetCounters return the collected constraint counters, if any
func (*ConstraintSystem) GetNbVariables ¶
func (cs *ConstraintSystem) GetNbVariables() (internal, secret, public int)
GetNbVariables return number of internal, secret and public variables
func (*ConstraintSystem) GetSchema ¶
func (cs *ConstraintSystem) GetSchema() *schema.Schema
type Counter ¶
type Counter struct {
From, To string
NbVariables int
NbConstraints int
CurveID ecc.ID
BackendID backend.ID
}
Counter contains measurements of useful statistics between two Tag
type Hint ¶
type Hint struct { ID hint.ID // hint function id Inputs []interface{} // terms to inject in the hint function Wires []int // IDs of wires the hint outputs map to }
Hint represents a solver hint it enables the solver to compute a Wire with a function provided at solving time using pre-defined inputs
func (Hint) MarshalCBOR ¶
func (*Hint) UnmarshalCBOR ¶
type LinearExpression ¶
type LinearExpression []Term
A linear expression is a linear combination of Term
func (LinearExpression) Clone ¶
func (l LinearExpression) Clone() LinearExpression
Clone returns a copy of the underlying slice
func (LinearExpression) Equal ¶
func (l LinearExpression) Equal(o LinearExpression) bool
Equals returns true if both SORTED expressions are the same
pre conditions: l and o are sorted
func (LinearExpression) HashCode ¶
func (l LinearExpression) HashCode() uint64
HashCode returns a fast-to-compute but NOT collision resistant hash code identifier for the linear expression
func (LinearExpression) Len ¶
func (l LinearExpression) Len() int
Len return the lenght of the Variable (implements Sort interface)
func (LinearExpression) Less ¶
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 ¶
func (l LinearExpression) Swap(i, j int)
Swap swaps terms in the Variable (implements Sort interface)
type LogEntry ¶
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) WriteVariable ¶
func (l *LogEntry) WriteVariable(le LinearExpression, sbb *strings.Builder)
type R1CS ¶
type R1CS struct { ConstraintSystem Constraints []R1C }
R1CS decsribes a set of R1C constraint
func (*R1CS) GetNbConstraints ¶
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)
type SparseR1CS ¶
type SparseR1CS struct { ConstraintSystem 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. A term packs wireID, coeffID, visibility and some metadata associated with the term, in a uint64. note: if we support more than 1 billion constraints, this breaks (not so soon.)
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 schema.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) SetCoeffID ¶
SetCoeffID update the bits correponding to the coeffID with cID
func (*Term) SetVariableVisibility ¶
func (t *Term) SetVariableVisibility(v schema.Visibility)
SetVariableVisibility update the bits correponding to the variableVisiblity with its encoding
func (Term) Unpack ¶
func (t Term) Unpack() (coeffID, variableID int, variableVisiblity schema.Visibility)
Unpack returns coeffID, variableID and visibility
func (Term) VariableVisibility ¶
func (t Term) VariableVisibility() schema.Visibility
VariableVisibility returns encoded schema.Visibility attribute