groth16

package
v0.3.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2020 License: Apache-2.0 Imports: 15 Imported by: 169

Documentation

Overview

Package groth16 implements Groth16 zkSNARK workflow (https://eprint.iacr.org/2016/260.pdf)

Index

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 NewAssert

func NewAssert(t *testing.T) *Assert

NewAssert returns an Assert helper

func (*Assert) ProverFailed

func (assert *Assert) ProverFailed(r1cs r1cs.R1CS, _solution interface{})

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

func (assert *Assert) ProverSucceeded(r1cs r1cs.R1CS, _solution interface{})

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

func (assert *Assert) SolvingFailed(r1cs r1cs.R1CS, _solution interface{})

SolvingFailed Verifies that the R1CS is not solved with the given solution, without executing groth16 workflow

func (*Assert) SolvingSucceeded

func (assert *Assert) SolvingSucceeded(r1cs r1cs.R1CS, _solution interface{})

SolvingSucceeded Verifies that the R1CS is solved with the given solution, without executing groth16 workflow

type Proof

type Proof interface {
	GetCurveID() gurvy.ID
}

Proof represents a Groth16 proof generated by groth16.Prove it's underlying implementation is curve specific (i.e bn256/groth16/Proof, ...)

func Prove

func Prove(r1cs r1cs.R1CS, pk ProvingKey, _solution interface{}) (Proof, error)

Prove generate a groth16.Proof it checks the underlying type of the R1CS (curve specific) to call the proper implementation

func ReadProof

func ReadProof(path string) (Proof, error)

ReadProof will read proof at given path into a curve-typed object note that until v1.X.X serialization (schema-less, disk, network, ..) may change

type ProvingKey

type ProvingKey interface {
	GetCurveID() gurvy.ID
	IsDifferent(interface{}) bool
}

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

type VerifyingKey interface {
	GetCurveID() gurvy.ID
	IsDifferent(interface{}) bool
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL