Documentation ¶
Overview ¶
Package groth16 implements Groth16 zkSNARK workflow (https://eprint.iacr.org/2016/260.pdf)
Index ¶
- func Setup(r1cs r1cs.R1CS) (ProvingKey, VerifyingKey)
- func Verify(proof Proof, vk VerifyingKey, _solution interface{}) error
- type Assert
- func (assert *Assert) ProverFailed(r1cs r1cs.R1CS, _solution interface{})
- func (assert *Assert) ProverSucceeded(r1cs r1cs.R1CS, _solution interface{})
- func (assert *Assert) SolvingFailed(r1cs r1cs.R1CS, _solution interface{})
- func (assert *Assert) SolvingSucceeded(r1cs r1cs.R1CS, _solution interface{})
- type Proof
- type ProvingKey
- type VerifyingKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Setup ¶
func Setup(r1cs r1cs.R1CS) (ProvingKey, VerifyingKey)
Setup runs groth16.Setup with provided R1CS it checks the underlying type of the R1CS (curve specific) to call the proper implementation
func Verify ¶
func Verify(proof Proof, vk VerifyingKey, _solution interface{}) error
Verify runs the groth16.Verify algorithm on provided proof with given solution it checks the underlying type of proof (i.e curve specific) to call the proper implementation
Types ¶
type Assert ¶
type Assert struct {
*require.Assertions
}
Assert is a helper to test circuits
func (*Assert) ProverFailed ¶
ProverFailed check that a solution does NOT solve a circuit error may be missing inputs or unsatisfied constraints it creates a groth16.ProvingKey for the r1cs run groth16.Prove (which solves the R1CS) and expects an error provided _solution must either implements frontend.Circuit or be a map[string]interface{}
func (*Assert) ProverSucceeded ¶
ProverSucceeded check that a solution solves a circuit for each expectedValues, this helper compares the output from backend.Inspect() after Solving. this helper also ensure the result vectors a*b=c it ensures running groth16.Prove and groth16.Verify returns true provided _solution must either implements frontend.Circuit or be a map[string]interface{}
func (*Assert) SolvingFailed ¶
SolvingFailed Verifies that the R1CS is not solved with the given solution, without executing groth16 workflow
func (*Assert) SolvingSucceeded ¶
SolvingSucceeded Verifies that the R1CS is solved with the given solution, without executing groth16 workflow
type Proof ¶
Proof represents a Groth16 proof generated by groth16.Prove it's underlying implementation is curve specific (i.e bn256/groth16/Proof, ...)
type ProvingKey ¶
ProvingKey represents a Groth16 ProvingKey it's underlying implementation is curve specific (i.e bn256/groth16/ProvingKey, ...)
func DummySetup ¶
func DummySetup(r1cs r1cs.R1CS) ProvingKey
DummySetup create a random ProvingKey with provided R1CS it doesn't return a VerifyingKey and is use for benchmarking or test purposes only.
func ReadProvingKey ¶
func ReadProvingKey(path string) (ProvingKey, error)
ReadProvingKey read file at path and attempt to decode it into a ProvingKey object note that until v1.X.X serialization (schema-less, disk, network, ..) may change
type VerifyingKey ¶
VerifyingKey represents a Groth16 VerifyingKey it's underlying implementation is curve specific (i.e bn256/groth16/VerifyingKey, ...)
func ReadVerifyingKey ¶
func ReadVerifyingKey(path string) (VerifyingKey, error)
ReadVerifyingKey read file at path and attempt to decode it into a VerifyingKey note that until v1.X.X serialization (schema-less, disk, network, ..) may change