succinct

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0, MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(c Circuit)

Types

type Circuit

type Circuit interface {
	GetInputBytes() *[]vars.Byte
	GetOutputBytes() *[]vars.Byte
	SetWitness(inputBytes []byte)
	Assign(inputBytes []byte) error
	Define(BaseApi frontend.API) error
}

Circuit is the interface a circuit interacting with the Succinct Hub must implement. These methods are used for loading witnesses into the circuit, defining constraints, and reading and writing data to Ethereum.

type CircuitBuild

type CircuitBuild struct {
	// contains filtered or unexported fields
}

func ImportCircuitBuild

func ImportCircuitBuild() (*CircuitBuild, error)

ImportCircuitBuild imports the R1CS, proving key, and verifying key from files.

func (*CircuitBuild) Export

func (build *CircuitBuild) Export()

Export exports the R1CS, proving key, and verifying key to files.

type CircuitFunction

type CircuitFunction struct {
	// The input hash is the hash of all onchain inputs into the function.
	InputHash vars.Variable `gnark:"inputHash,public"`

	// The output hash is the hash of all outputs from the function.
	OutputHash vars.Variable `gnark:"outputHash,public"`

	// The circuit definies the computation of the function.
	Circuit Circuit
}

Circuit functions are circuits that want to be deployed as onchain functions.

func NewCircuitFunction

func NewCircuitFunction(c Circuit) CircuitFunction

Creates a new circuit function based on a circuit that implements the Circuit interface.

func (*CircuitFunction) Build

func (circuit *CircuitFunction) Build() (*CircuitBuild, error)

Build the circuit and serialize the r1cs, proving key, and verifying key to files.

func (*CircuitFunction) Define

func (f *CircuitFunction) Define(baseApi frontend.API) error

Define the circuit. All circuit functions automatically constraint h(inputBytes) == inputHash and h(outputBytes) == outputHash.

func (*CircuitFunction) GenerateFixture

func (f *CircuitFunction) GenerateFixture(inputBytes []byte) (types.Fixture, error)

Generates a JSON fixture for use in Solidity tests with MockSuccinctGateway.sol.

func (*CircuitFunction) Prove

func (f *CircuitFunction) Prove(inputBytes []byte, build *CircuitBuild) (*types.Groth16Proof, error)

Generates a proof for f(inputs, witness) = outputs based on a circuit.

func (*CircuitFunction) SetWitness

func (f *CircuitFunction) SetWitness(inputBytes []byte)

Generate and set witnesses for the circuit function. In particular, this function will set the input hash and output hash variables (which will be public values). Recall that all functions have the form f(inputs, witness) = outputs. Both inputsHash and outputsHash are h(inputs) and h(outputs) respectively, where h is a hash function.

type SuccinctVerifyingKey

type SuccinctVerifyingKey struct {
	groth16.VerifyingKey
}

func (*SuccinctVerifyingKey) ExportIFunctionVerifierSolidity

func (svk *SuccinctVerifyingKey) ExportIFunctionVerifierSolidity(w io.Writer) error

Jump to

Keyboard shortcuts

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