Documentation
¶
Index ¶
- Constants
- type LinearExpression
- type LogEntry
- type R1C
- type R1CS
- func (r1cs *R1CS) CurveID() ecc.ID
- func (r1cs *R1CS) FrSize() int
- func (r1cs *R1CS) GetNbCoefficients() int
- func (r1cs *R1CS) GetNbConstraints() int
- func (r1cs *R1CS) GetNbVariables() (internal, secret, public int)
- func (r1cs *R1CS) ReadFrom(r io.Reader) (n int64, err error)
- func (r1cs *R1CS) SetLoggerOutput(w io.Writer)
- func (r1cs *R1CS) WriteTo(w io.Writer) (n int64, err error)
- type SolvingMethod
- type SparseR1C
- type SparseR1CS
- func (cs *SparseR1CS) CurveID() ecc.ID
- func (cs *SparseR1CS) FrSize() int
- func (cs *SparseR1CS) GetNbCoefficients() int
- func (cs *SparseR1CS) GetNbConstraints() int
- func (cs *SparseR1CS) GetNbVariables() (internal, secret, public int)
- func (cs *SparseR1CS) GetNbWires() int
- func (cs *SparseR1CS) ReadFrom(r io.Reader) (n int64, err error)
- func (cs *SparseR1CS) SetLoggerOutput(w io.Writer)
- func (cs *SparseR1CS) WriteTo(w io.Writer) (n int64, err error)
- 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.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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)
type R1C ¶
type R1C struct {
L LinearExpression
R LinearExpression
O LinearExpression
Solver SolvingMethod
}
R1C used to compute the wires
type R1CS ¶
type R1CS struct {
// Wires
NbInternalVariables int
NbPublicVariables int // includes ONE wire
NbSecretVariables int
Logs []LogEntry
DebugInfo []LogEntry
// Constraints
NbConstraints int // total number of constraints
NbCOConstraints int // number of constraints that need to be solved, the first of the Constraints slice
Constraints []R1C
}
R1CS decsribes a set of R1CS constraint The coefficients from the rank-1 constraint it contains are big.Int and not tied to a curve base field
func (*R1CS) GetNbCoefficients ¶
GetNbCoefficients return the number of unique coefficients needed in the R1CS
func (*R1CS) GetNbConstraints ¶
GetNbConstraints returns the number of constraints
func (*R1CS) GetNbVariables ¶
GetNbVariables return number of internal, secret and public variables
func (*R1CS) SetLoggerOutput ¶
SetLoggerOutput replace existing logger output with provided one default uses os.Stdout if nil is provided, logs are not printed
type SolvingMethod ¶
type SolvingMethod uint8
SolvingMethod is used by the R1CS solver note: it is not in backend/r1cs to avoid an import cycle
const ( SingleOutput SolvingMethod = iota BinaryDec )
SingleOuput and BinaryDec are types of solving method for rank-1 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
Solver SolvingMethod
}
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 {
// Variables [publicVariables| secretVariables | internalVariables ]
NbInternalVariables int
NbPublicVariables int
NbSecretVariables int
// Constraints
Constraints []SparseR1C // list of PLONK constraints that yield an output (for example v3 == v1 * v2, return v3)
Assertions []SparseR1C // list of PLONK constraints that yield no output (for example ensuring v1 == v2)
// Logs (e.g. variables that have been printed using cs.Println)
Logs []LogEntry
}
SparseR1CS represents a Plonk like circuit
func (*SparseR1CS) CurveID ¶
func (cs *SparseR1CS) CurveID() ecc.ID
CurveID returns ecc.UNKNOWN as this is a untyped R1CS using big.Int
func (*SparseR1CS) GetNbCoefficients ¶
func (cs *SparseR1CS) GetNbCoefficients() int
GetNbCoefficients return the number of unique coefficients needed in the R1CS
func (*SparseR1CS) GetNbConstraints ¶
func (cs *SparseR1CS) GetNbConstraints() int
GetNbConstraints returns the number of constraints
func (*SparseR1CS) GetNbVariables ¶
func (cs *SparseR1CS) GetNbVariables() (internal, secret, public int)
GetNbVariables return number of internal, secret and public variables
func (*SparseR1CS) GetNbWires ¶
func (cs *SparseR1CS) GetNbWires() int
GetNbWires returns the number of wires (internal)
func (*SparseR1CS) ReadFrom ¶
func (cs *SparseR1CS) ReadFrom(r io.Reader) (n int64, err error)
ReadFrom panics
func (*SparseR1CS) SetLoggerOutput ¶
func (cs *SparseR1CS) SetLoggerOutput(w io.Writer)
SetLoggerOutput replace existing logger output with provided one default uses os.Stdout if nil is provided, logs are not printed
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.)
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 )