Documentation ¶
Index ¶
- Constants
- type CS
- func (cs *CS) CurveID() ecc.ID
- func (cs *CS) FrSize() int
- func (cs *CS) GetNbCoefficients() int
- func (cs *CS) GetNbVariables() (internal, secret, public int)
- 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 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) SetVariableID(cID int)
- func (t *Term) SetVariableVisibility(v Visibility)
- func (t Term) Unpack() (coeffID, variableID int, variableVisiblity Visibility)
- func (t Term) VariableID() int
- func (t Term) VariableVisibility() Visibility
- type Visibility
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 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) 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 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 ¶
func (l LinearExpression) Clone() LinearExpression
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 ¶
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
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 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) SetVariableID ¶
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 ¶
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 )