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: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DummySetup

func DummySetup(r1cs *bls377backend.R1CS, pk *ProvingKey)

DummySetup fills a random ProvingKey used for test or benchmarking purposes

func ParsePublicInput

func ParsePublicInput(expectedNames []string, input map[string]interface{}) ([]fr.Element, error)

ParsePublicInput return the ordered public input values in regular form (used as scalars for multi exponentiation). The function is public because it's needed for the recursive snark.

func Setup

func Setup(r1cs *bls377backend.R1CS, pk *ProvingKey, vk *VerifyingKey)

Setup constructs the SRS

func Verify

func Verify(proof *Proof, vk *VerifyingKey, inputs map[string]interface{}) error

Verify verifies a proof

Types

type Proof

type Proof struct {
	Ar, Krs curve.G1Affine
	Bs      curve.G2Affine
}

Proof represents a Groth16 proof that was encoded with a ProvingKey and can be verified with a valid statement and a VerifyingKey

func Prove

func Prove(r1cs *bls377backend.R1CS, pk *ProvingKey, solution map[string]interface{}) (*Proof, error)

Prove creates proof from a circuit

func (*Proof) GetCurveID

func (proof *Proof) GetCurveID() gurvy.ID

GetCurveID returns the curveID

type ProvingKey

type ProvingKey struct {
	// [α]1, [β]1, [δ]1
	// [A(t)]1, [B(t)]1, [Kpk(t)]1, [Z(t)]1
	G1 struct {
		Alpha, Beta, Delta curve.G1Affine
		A, B, Z            []curve.G1Affine
		K                  []curve.G1Affine // the indexes correspond to the private wires
	}

	// [β]2, [δ]2, [B(t)]2
	G2 struct {
		Beta, Delta curve.G2Affine
		B           []curve.G2Affine
	}
}

ProvingKey is used by a Groth16 prover to encode a proof of a statement

func (*ProvingKey) GetCurveID

func (pk *ProvingKey) GetCurveID() gurvy.ID

GetCurveID returns the curveID

func (*ProvingKey) IsDifferent

func (pk *ProvingKey) IsDifferent(_other interface{}) bool

IsDifferent returns true if provided pk is different than self this is used by groth16.Assert to ensure random sampling

type VerifyingKey

type VerifyingKey struct {
	// e(α, β)
	E curve.PairingResult

	// -[γ]2, -[δ]2
	// note: storing GammaNeg and DeltaNeg instead of Gamma and Delta
	// see proof.Verify() for more details
	G2 struct {
		GammaNeg, DeltaNeg curve.G2Affine
	}

	// [Kvk]1
	G1 struct {
		K []curve.G1Affine // The indexes correspond to the public wires
	}

	PublicInputs []string // maps the name of the public input
}

VerifyingKey is used by a Groth16 verifier to verify the validity of a proof and a statement

func (*VerifyingKey) GetCurveID

func (pk *VerifyingKey) GetCurveID() gurvy.ID

GetCurveID returns the curveID

func (*VerifyingKey) IsDifferent

func (vk *VerifyingKey) IsDifferent(_other interface{}) bool

IsDifferent returns true if provided vk is different than self this is used by groth16.Assert to ensure random sampling

Jump to

Keyboard shortcuts

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