plonk

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: Apache-2.0 Imports: 34 Imported by: 53

Documentation

Overview

Package plonk implements PLONK Zero Knowledge Proof system.

See also

https://eprint.iacr.org/2019/953

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsSolved

func IsSolved(ccs frontend.CompiledConstraintSystem, witness frontend.Circuit, opts ...func(opt *backend.ProverOption) error) error

IsSolved attempts to solve the constraint system with provided witness returns nil if it succeeds, error otherwise.

func NewCS added in v0.5.0

func NewCS(curveID ecc.ID) frontend.CompiledConstraintSystem

NewCS instantiate a concrete curved-typed SparseR1CS and return a CompiledConstraintSystem interface This method exists for (de)serialization purposes

func NewSRS added in v0.5.0

NewSRS uses ccs nb variables and nb constraints to initialize a kzg srs note that this method is here for convenience only: in production, a SRS generated through MPC should be used.

func ReadAndVerify added in v0.5.0

func ReadAndVerify(proof Proof, vk VerifyingKey, witness io.Reader) error

ReadAndVerify verifies a PLONK proof from a circuit, associated proving key, and the full witness

func Setup

Setup prepares the public data associated to a circuit + public inputs.

func Verify

func Verify(proof Proof, vk VerifyingKey, publicWitness frontend.Circuit) error

Verify verifies a PLONK proof, from the proof, preprocessed public data, and public witness.

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(ccs frontend.CompiledConstraintSystem, witness frontend.Circuit, opts ...func(opt *backend.ProverOption) error)

func (*Assert) ProverSucceeded

func (assert *Assert) ProverSucceeded(ccs frontend.CompiledConstraintSystem, witness frontend.Circuit, opts ...func(opt *backend.ProverOption) error)

func (*Assert) SolvingFailed

func (assert *Assert) SolvingFailed(ccs frontend.CompiledConstraintSystem, witness frontend.Circuit)

SolvingFailed Verifies that the cs.PCS is not solved with the given witness, without executing plonk workflow

func (*Assert) SolvingSucceeded

func (assert *Assert) SolvingSucceeded(ccs frontend.CompiledConstraintSystem, witness frontend.Circuit)

SolvingSucceeded Verifies that the sparse constraint system is solved with the given witness, without executing plonk workflow

type Proof

type Proof interface {
	io.WriterTo
	io.ReaderFrom
}

Proof represents a Plonk proof generated by plonk.Prove

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

func NewProof added in v0.5.0

func NewProof(curveID ecc.ID) Proof

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

func Prove

func Prove(ccs frontend.CompiledConstraintSystem, pk ProvingKey, fullWitness frontend.Circuit, opts ...func(opt *backend.ProverOption) error) (Proof, error)

Prove generates PLONK proof from a circuit, associated preprocessed public data, and the witness if the force flag is set:

	will executes all the prover computations, even if the witness is invalid
 will produce an invalid proof
	internally, the solution vector to the SparseR1CS will be filled with random values which may impact benchmarking

func ReadAndProve added in v0.5.0

func ReadAndProve(ccs frontend.CompiledConstraintSystem, pk ProvingKey, witness io.Reader, opts ...func(opt *backend.ProverOption) error) (Proof, error)

ReadAndProve generates PLONK proof from a circuit, associated proving key, and the full witness

type ProvingKey added in v0.5.0

type ProvingKey interface {
	io.WriterTo
	io.ReaderFrom
	InitKZG(srs kzg.SRS) error
	VerifyingKey() interface{}
}

ProvingKey represents a plonk ProvingKey

it's underlying implementation is strongly typed with the curve (see gnark/internal/backend)

func NewProvingKey added in v0.5.0

func NewProvingKey(curveID ecc.ID) ProvingKey

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

type VerifyingKey added in v0.5.0

type VerifyingKey interface {
	io.WriterTo
	io.ReaderFrom
	InitKZG(srs kzg.SRS) error
	NbPublicWitness() int // number of elements expected in the public witness
}

VerifyingKey represents a plonk VerifyingKey

it's underlying implementation is strongly typed with the curve (see gnark/internal/backend)

func NewVerifyingKey added in v0.5.0

func NewVerifyingKey(curveID ecc.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