Documentation ¶
Index ¶
- type R1CS
- func (cs *R1CS) CurveID() ecc.ID
- func (cs *R1CS) FrSize() int
- func (cs *R1CS) GetConstraints() [][]string
- func (cs *R1CS) GetNbCoefficients() int
- func (cs *R1CS) IsSolved(witness *witness.Witness, opts ...backend.ProverOption) error
- func (cs *R1CS) ReadFrom(r io.Reader) (int64, error)
- func (cs *R1CS) Solve(witness, a, b, c []fr.Element, opt backend.ProverConfig) ([]fr.Element, error)
- func (cs *R1CS) WriteTo(w io.Writer) (int64, error)
- type SparseR1CS
- func (cs *SparseR1CS) CurveID() ecc.ID
- func (cs *SparseR1CS) FrSize() int
- func (cs *SparseR1CS) GetConstraints() [][]string
- func (cs *SparseR1CS) GetNbCoefficients() int
- func (cs *SparseR1CS) IsSolved(witness *witness.Witness, opts ...backend.ProverOption) error
- func (cs *SparseR1CS) ReadFrom(r io.Reader) (int64, error)
- func (cs *SparseR1CS) Solve(witness []fr.Element, opt backend.ProverConfig) ([]fr.Element, error)
- func (cs *SparseR1CS) WriteTo(w io.Writer) (int64, error)
- type UnsatisfiedConstraintError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type R1CS ¶
R1CS describes a set of R1CS constraint
func NewR1CS ¶
NewR1CS returns a new R1CS and sets cs.Coefficient (fr.Element) from provided big.Int values
func (*R1CS) GetConstraints ¶
GetConstraints return a list of constraint formatted as L⋅R == O such that [0] -> L, [1] -> R, [2] -> O
func (*R1CS) GetNbCoefficients ¶
GetNbCoefficients return the number of unique coefficients needed in the R1CS
func (*R1CS) IsSolved ¶
IsSolved returns nil if given witness solves the R1CS and error otherwise this method wraps cs.Solve() and allocates cs.Solve() inputs
func (*R1CS) Solve ¶
func (cs *R1CS) Solve(witness, a, b, c []fr.Element, opt backend.ProverConfig) ([]fr.Element, error)
Solve sets all the wires and returns the a, b, c vectors. the cs system should have been compiled before. The entries in a, b, c are in Montgomery form. a, b, c vectors: ab-c = hz witness = [publicWires | secretWires] (without the ONE_WIRE !) returns [publicWires | secretWires | internalWires ]
type SparseR1CS ¶
type SparseR1CS struct { compiled.SparseR1CS Coefficients []fr.Element // coefficients in the constraints }
SparseR1CS represents a Plonk like circuit
func NewSparseR1CS ¶
func NewSparseR1CS(ccs compiled.SparseR1CS, coefficients []big.Int) *SparseR1CS
NewSparseR1CS returns a new SparseR1CS and sets r1cs.Coefficient (fr.Element) from provided big.Int values
func (*SparseR1CS) CurveID ¶
func (cs *SparseR1CS) CurveID() ecc.ID
CurveID returns curve ID as defined in gnark-crypto (ecc.BN254)
func (*SparseR1CS) FrSize ¶
func (cs *SparseR1CS) FrSize() int
FrSize return fr.Limbs * 8, size in byte of a fr element
func (*SparseR1CS) GetConstraints ¶
func (cs *SparseR1CS) GetConstraints() [][]string
GetConstraints return a list of constraint formatted as in the paper https://eprint.iacr.org/2019/953.pdf section 6 such that qL⋅xa + qR⋅xb + qO⋅xc + qM⋅(xaxb) + qC == 0 each constraint is thus decomposed in [5]string with
[0] = qL⋅xa [1] = qR⋅xb [2] = qO⋅xc [3] = qM⋅(xaxb) [4] = qC
func (*SparseR1CS) GetNbCoefficients ¶
func (cs *SparseR1CS) GetNbCoefficients() int
GetNbCoefficients return the number of unique coefficients needed in the R1CS
func (*SparseR1CS) IsSolved ¶
func (cs *SparseR1CS) IsSolved(witness *witness.Witness, opts ...backend.ProverOption) error
IsSolved returns nil if given witness solves the SparseR1CS and error otherwise this method wraps cs.Solve() and allocates cs.Solve() inputs
func (*SparseR1CS) ReadFrom ¶
func (cs *SparseR1CS) ReadFrom(r io.Reader) (int64, error)
ReadFrom attempts to decode SparseR1CS from io.Reader using cbor
func (*SparseR1CS) Solve ¶
func (cs *SparseR1CS) Solve(witness []fr.Element, opt backend.ProverConfig) ([]fr.Element, error)
Solve sets all the wires. solution.values = [publicInputs | secretInputs | internalVariables ] witness: contains the input variables it returns the full slice of wires
type UnsatisfiedConstraintError ¶
type UnsatisfiedConstraintError struct { Err error CID int // constraint ID DebugInfo *string // optional debug info }
UnsatisfiedConstraintError wraps an error with useful metadata on the unsatisfied constraint
func (*UnsatisfiedConstraintError) Error ¶
func (r *UnsatisfiedConstraintError) Error() string