groth16

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

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 GetBN256Proof

func GetBN256Proof(path string) groth16_bn256.Proof

GetBN256Proof returns an empty proof

func Setup

func Setup(r1cs r1cs.R1CS) (ProvingKey, VerifyingKey)

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()

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 {
	io.CurveObject
}

Proof represents a Groth16 proof generated by groth16.Prove

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

func Prove

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

Prove generate a groth16.Proof

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 {
	io.CurveObject
	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

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 {
	io.CurveObject
	IsDifferent(interface{}) bool
}

VerifyingKey represents a Groth16 VerifyingKey

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

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