Documentation
¶
Overview ¶
Package groth16 exposes zkSNARK (Groth16) 3 algorithms: Setup, Prove and Verify
Index ¶
- Variables
- func BenchmarkProver(b *testing.B, circuit cs.CS, solution cs.Assignments)
- func BenchmarkSetup(b *testing.B, circuit cs.CS)
- func BenchmarkVerifier(b *testing.B, circuit cs.CS, solution cs.Assignments)
- func ParsePublicInput(expectedNames []string, publicInput map[string]cs.Assignment) ([]curve.Element, error)
- func Setup(r1cs *cs.R1CS, pk *ProvingKey, vk *VerifyingKey)
- func Verify(proof *Proof, vk *VerifyingKey, publicInputs map[string]cs.Assignment) (bool, error)
- type Assert
- type Proof
- type ProvingKey
- type VerifyingKey
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func BenchmarkProver ¶
BenchmarkProver is a helper to benchmark groth16.Prove on a given circuit it will run the Setup, reset the benchmark timer and benchmark the prover
func BenchmarkSetup ¶
BenchmarkSetup is a helper to benchmark groth16.Setup on a given circuit
func BenchmarkVerifier ¶
BenchmarkVerifier is a helper to benchmark groth16.Verify on a given circuit it will run the Setup, the Prover and reset the benchmark timer and benchmark the verifier the provided solution will be filtered to keep only public inputs
func ParsePublicInput ¶
func ParsePublicInput(expectedNames []string, publicInput map[string]cs.Assignment) ([]curve.Element, error)
ParsePublicInput return the input values, not in Montgomery form
func Verify ¶
func Verify(proof *Proof, vk *VerifyingKey, publicInputs map[string]cs.Assignment) (bool, error)
Verify verifies a proof
Types ¶
type Assert ¶
type Assert struct { *require.Assertions // contains filtered or unexported fields }
Assert is a helper to test circuits it embeds a cs.Assert object (see gnark/cs/assert)
func (*Assert) NotSolved ¶
func (assert *Assert) NotSolved(circuit cs.CS, solution cs.Assignments)
NotSolved check that a solution does NOT solve a circuit error may be missing inputs or unsatisfied constraints it runs cs.Assert.NotSolved and ensure running groth16.Prove and groth16.Verify doesn't return true
func (*Assert) Solved ¶
func (assert *Assert) Solved(circuit cs.CS, solution cs.Assignments, expectedValues map[string]interface{})
Solved check that a solution solves a circuit for each expectedValues, this helper compares the output from r1cs.Inspect() after Solving. this helper also ensure the result vectors a*b=c it runs cs.Assert.Solved and ensure running groth16.Prove and groth16.Verify returns true
type Proof ¶
Proof represents a Groth16 proof that was encoded with a ProvingKey and can be verified with a valid statement and a VerifyingKey
func Prove ¶
func Prove(r1cs *cs.R1CS, pk *ProvingKey, solution map[string]cs.Assignment) (*Proof, error)
Prove creates proof from a circuit
type ProvingKey ¶
type ProvingKey struct { // [α]1, [β]1, [δ]1 // [A(t)]1, [B(t)]1, [Kpk(t)]1, [Z(t)]1 G1 struct { Alpha, Beta, Delta ecc.G1Affine A, B, Z []ecc.G1Affine K []ecc.G1Affine // the indexes correspond to the private wires } // [β]2, [δ]2, [B(t)]2 G2 struct { Beta, Delta ecc.G2Affine B []ecc.G2Affine } }
ProvingKey is used by a Groth16 prover to encode a proof of a statement
type VerifyingKey ¶
type VerifyingKey struct { // e(α, β) E ecc.PairingResult // -[γ]2, -[δ]2 // note: storing GammaNeg and DeltaNeg instead of Gamma and Delta // see proof.Verify() for more details G2Aff struct { GammaNeg, DeltaNeg ecc.G2Affine } // [Kvk]1 G1Jac struct { K []ecc.G1Jac // The indexes correspond to the public wires } PublicInputsTracker []string // maps the name of the public input }
VerifyingKey is used by a Groth16 verifier to verify the validity of a proof and a statement