zkpbinding

package
v0.0.0-...-886a677 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package zkpbinding contains a set of helper functions aimed to generate and interact with Verifier smart contract written in Go and using Groth-16 proving system over BLS12-381 elliptic curve to verify proofs. Package zkpbinding provides the Veifier contract generation functionality itself as far as a helper that converts groth16.Proof to the Verifier-specific set of arguments.

Please, check out the example of zkpbinding package usage to generate and verify proofs on the Neo chain: https://github.com/epicchainlabs/epicchain-go/blob/91c928e8d35164055e5b2e8efbc898440cc2b486/examples/zkp/cubic_circuit/README.md

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateVerifier

func GenerateVerifier(cfg Config) error

GenerateVerifier generates a Verifier smart contract written in Go for Neo blockchain. The contract contains a single `verifyProof` method that accepts a proof represented as three BLS12-381 curve points and public witnesses required for verification represented as a list of serialized 32-bytes field elements in the LE form. The boolean result of `verifyProof` is either `true` (if the proof is valid) or `false` (if the proof is invalid). The smart contract generated from this template can be immediately compiled without any additional changes using NeoGo compiler, deployed to the Neo chain and invoked. The verification contract is circuit-specific, i.e. corresponds to a specific constraint system. Thus, every new circuit requires its own verification contract to be generated and deployed to the chain.

GenerateVerifier also generates a proper contract YAML configuration file, go.mod and go.sum files if the corresponding writers are provided via cfg.

Types

type Config

type Config struct {
	// VerifyingKey must be a Groth-16 BLS12-381 specific verifier key,
	// parameters of which will be used to generate Verifier Neo smart contract.
	VerifyingKey groth16.VerifyingKey
	// Output is a writer for the resulting Verifier Go smart contract, it must
	// not be nil.
	Output io.Writer
	// CfgOutput is a writer for the resulting Verifier Go smart contract YAML
	// configuration file needed to compile the contract. It may be nil if the
	// contract configuration file generation should be omitted.
	CfgOutput io.Writer
	// GomodOutput is a writer for the resulting go.mod file of the Verifier Go
	// smart contract needed to compile it. It may be nil if the go.mod file
	// generation should be omitted.
	GomodOutput io.Writer
	// GosumOutput is a writer for the resulting go.sum file of the Verifier Go
	// smart contract needed to compile it. It may be nil if the go.sum file
	// generation should be omitted.
	GosumOutput io.Writer
}

Config represents a configuration for Verifier Go smart contract generator.

type VerifyProofArgs

type VerifyProofArgs struct {
	A               []byte
	B               []byte
	C               []byte
	PublicWitnesses []any
}

VerifyProofArgs is the set of arguments of `verifyProof` method of a Verifier contract in serialized form (as the contract accepts them).

func GetVerifyProofArgs

func GetVerifyProofArgs(proof groth16.Proof, publicWitness witness.Witness) (*VerifyProofArgs, error)

GetVerifyProofArgs returns a serialized set of arguments `verifyProof` method of a generated Verifier contract accepts. The set of arguments may be directly used as parameters to contract invocation.

Jump to

Keyboard shortcuts

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