Documentation ¶
Index ¶
- Constants
- type CS
- func (cs *CS) CurveID() ecc.ID
- func (cs *CS) FrSize() int
- func (cs *CS) GetConstraints() [][]string
- func (cs *CS) GetCounters() []Counter
- func (cs *CS) GetNbCoefficients() int
- func (cs *CS) GetNbVariables() (internal, secret, public int)
- func (cs *CS) GetSchema() *schema.Schema
- func (cs *CS) ReadFrom(r io.Reader) (n int64, err error)
- func (cs *CS) ToHTML(w io.Writer) error
- func (cs *CS) WriteTo(w io.Writer) (n int64, err error)
- 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
- type Variable
Constants ¶
const ( CoeffIdZero = 0 CoeffIdOne = 1 CoeffIdTwo = 2 CoeffIdMinusOne = 3 )
ids of the coefficients with simple values in any cs.coeffs slice.
const R1CSTemplate = `` /* 1953-byte string literal not displayed */
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 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 // a wire may point to at most one hint MHints map[int]*Hint Schema *schema.Schema // 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 }
CS contains common element between R1CS and CS
func (*CS) GetConstraints ¶ added in v0.6.1
func (*CS) GetCounters ¶ added in v0.6.0
GetCounters return the collected constraint counters, if any
func (*CS) GetNbCoefficients ¶ added in v0.5.1
GetNbCoefficients panics
func (*CS) GetNbVariables ¶ added in v0.5.1
GetNbVariables return number of internal, secret and public variables
type Counter ¶ added in v0.6.0
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 ¶ added in v0.5.1
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 ¶ added in v0.6.0
func (*Hint) UnmarshalCBOR ¶ added in v0.6.0
type LinearExpression ¶
type LinearExpression []Term
func (LinearExpression) Equal ¶ added in v0.5.2
func (v LinearExpression) Equal(o LinearExpression) bool
Equals returns true if both SORTED expressions are the same
pre conditions: l and o are sorted
func (LinearExpression) Len ¶ added in v0.5.0
func (v LinearExpression) Len() int
Len return the lenght of the Variable (implements Sort interface)
func (LinearExpression) Less ¶ added in v0.5.0
func (v 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 (v 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)
type R1CS ¶
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 ¶
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.)
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) SetWireID ¶ added in v0.6.0
SetWireID update the bits correponding to the variableID with cID
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
type Variable ¶ added in v0.6.0
type Variable struct { LinExp LinearExpression IsBoolean *bool }
Variable represent a linear expression of wires
func (Variable) AssertIsSet ¶ added in v0.6.0
func (v Variable) AssertIsSet()
assertIsSet panics if the variable is unset this may happen if inside a Define we have var a variable cs.Mul(a, 1) since a was not in the circuit struct it is not a secret variable
func (*Variable) IsConstant ¶ added in v0.6.0
isConstant returns true if the variable is ONE_WIRE * coeff