groth16

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2020 License: Apache-2.0 Imports: 17 Imported by: 152

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, error)

Setup runs groth16.Setup with provided R1CS

func Verify

func Verify(proof Proof, vk VerifyingKey, solution interface{}) error

Verify runs the groth16.Verify algorithm on provided proof with given solution

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

solution must be map[string]interface{} or must implement frontend.Circuit ( see frontend.ParseWitness )

func (*Assert) ProverSucceeded

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

ProverSucceeded check that a solution solves a circuit

solution must be map[string]interface{} or must implement frontend.Circuit ( see frontend.ParseWitness )

1. Runs groth16.Setup()

2. Solves the R1CS

3. Runs groth16.Prove()

4. Runs groth16.Verify()

5. Ensure deserialization(serialization) of generated objects is correct

ensure result vectors a*b=c, and check other properties like random sampling

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

solution must be map[string]interface{} or must implement frontend.Circuit ( see frontend.ParseWitness )

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

solution must be map[string]interface{} or must implement frontend.Circuit ( see frontend.ParseWitness )

type Proof

type Proof interface {
	gnarkio.WriterRawTo
	io.WriterTo
	io.ReaderFrom
}

Proof represents a Groth16 proof generated by groth16.Prove

it's underlying implementation is curve specific (see gnark/internal/backend)

func NewProof added in v0.3.6

func NewProof(curveID gurvy.ID) Proof

NewProof instantiates a curve-typed Proof and returns an interface This function exists for serialization purposes

func Prove

func Prove(r1cs r1cs.R1CS, pk ProvingKey, solution interface{}, force ...bool) (Proof, error)

Prove generates the proof of knoweldge of a r1cs with solution. if force flag is set, Prove ignores R1CS solving error (ie invalid solution) and executes the FFTs and MultiExponentiations to compute an (invalid) Proof object

type ProvingKey

type ProvingKey interface {
	gnarkio.WriterRawTo
	io.WriterTo
	io.ReaderFrom
	IsDifferent(interface{}) bool
}

ProvingKey represents a Groth16 ProvingKey

it's underlying implementation is curve specific (see gnark/internal/backend)

func DummySetup

func DummySetup(r1cs r1cs.R1CS) (ProvingKey, error)

DummySetup create a random ProvingKey with provided R1CS it doesn't return a VerifyingKey and is use for benchmarking or test purposes only.

func NewProvingKey added in v0.3.6

func NewProvingKey(curveID gurvy.ID) ProvingKey

NewProvingKey instantiates a curve-typed ProvingKey and returns an interface object This function exists for serialization purposes

type VerifyingKey

type VerifyingKey interface {
	gnarkio.WriterRawTo
	io.WriterTo
	io.ReaderFrom
	IsDifferent(interface{}) bool
}

VerifyingKey represents a Groth16 VerifyingKey

it's underlying implementation is curve specific (see gnark/internal/backend)

func NewVerifyingKey added in v0.3.6

func NewVerifyingKey(curveID gurvy.ID) VerifyingKey

NewVerifyingKey instantiates a curve-typed VerifyingKey and returns an interface This function exists for serialization purposes

Jump to

Keyboard shortcuts

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