ExpanderCompilerCollection

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2024 License: AGPL-3.0 Imports: 9 Imported by: 16

README

Expander

ExpanderCompilerCollection

Expander is a proof generation backend for the Polyhedra Network. The ExpanderCompilerCollection is a component of the Expander proof system. It transforms circuits written in gnark into an intermediate representation (IR) of a layered circuit. This IR can later be used by the Expander prover to generate proofs.

Using this Library

To incorporate the compiler into your Go project, include the following import statement in your code:

import "github.com/PolyhedraZK/ExpanderCompilerCollection"

The APIs for this library are detailed in APIs.

Example

Refer to this example for a practical demonstration of our compiler. In this example, we illustrate how a gnark circuit can be compiled using ExpanderCompilerCollection. The output of this example includes a circuit description file "circuit.txt" and a corresponding witnesses file "witness.txt". Our prover, Expander, utilizes these IRs to generate the actual proof.

Additional examples include:

Deeper Dive in to the tech

For a more technical overview of the overall architecture, visit our Compilation Process document.

For a detailed explanation of the primary compilation artifacts - the layered circuit and the input solver, as well as their respective serialization formats, refer to Artifact and Serialization.

Acknowledgement

We extend our gratitude to the following projects, whose prior work has been crucial in bringing this project to fruition:

gnark: our frontend language is based on gnark's frontend.

Future roadmap

As a compiler collection, we will support more circuit frontend languages in near term.

Features in progress

  • On-chain verifier generation
  • Extended in-circuit randomness generation

Documentation

Overview

Package ExpanderCompilerCollection wraps the most commonly used compiler APIs and provides an entry point for compilation. This package simplifies the interaction with the compiler by exposing a unified API interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeserializeInputSolver

func DeserializeInputSolver(buf []byte) *ir.InputSolver

DeserializeInputSolver takes a byte buffer and returns a pointer to an ir.InputSolver which represents a deserialized input solver.

func DeserializeLayeredCircuit

func DeserializeLayeredCircuit(buf []byte) *layered.RootCircuit

DeserializeLayeredCircuit takes a byte buffer and returns a pointer to a layered.RootCircuit which represents a deserialized layered circuit.

func ProfilingCompile

func ProfilingCompile(field *big.Int, circuit frontend.Circuit, opts ...frontend.CompileOption) error

ProfilingCompile compiles the given circuit with profiling enabled, outputting the cost of each line of code. It does not return a compilation result as it does not complete the actual compilation process. Profiling is useful for performance analysis and optimization. TODO: Add support for sub-circuit profiling.

Types

type API

type API interface {
	frontend.API
	builder.SubCircuitAPI
	builder.API
}

API encapsulates the ExpanderCompilerCollection's frontend.API along with two new APIs added to facilitate direct invocation of ExpanderCompilerCollection.API within the codebase.

type CompileResult

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

CompileResult represents the result of a compilation process. It contains unexported fields and provides methods to retrieve various components like the intermediate representation (IR) of the circuit, the InputSolver, and the Layered Circuit.

func Compile

func Compile(field *big.Int, circuit frontend.Circuit, opts ...frontend.CompileOption) (*CompileResult, error)

Compile is similar to gnark's frontend.Compile. It compiles the given circuit and returns a pointer to CompileResult along with any error encountered during the compilation process.

func (*CompileResult) GetCircuitIr

func (c *CompileResult) GetCircuitIr() *ir.RootCircuit

GetCircuitIr returns the intermediate representation (IR) of the compiled circuit as *ir.RootCircuit.

func (*CompileResult) GetInputSolver

func (c *CompileResult) GetInputSolver() *ir.InputSolver

GetLayeredCircuit returns the Layered Circuit component of the compilation result as *layered.RootCircuit.

func (*CompileResult) GetLayeredCircuit

func (c *CompileResult) GetLayeredCircuit() *layered.RootCircuit

GetInputSolver returns the InputSolver component of the compilation result as *ir.InputSolver.

Directories

Path Synopsis
Package builder provides an implementation based on the gnark frontend builder with the following modifications: - LinearExpression has been changed to allow for quadratic terms in the form of Expression.
Package builder provides an implementation based on the gnark frontend builder with the following modifications: - LinearExpression has been changed to allow for quadratic terms in the form of Expression.
examples module
An expression supporting quadratic terms, implemented based on gnark `frontend/internal/expr`.
An expression supporting quadratic terms, implemented based on gnark `frontend/internal/expr`.
gf2
m31
Package ir implements the internal representation (IR) and related functionalities for the GKR compiler.
Package ir implements the internal representation (IR) and related functionalities for the GKR compiler.
Package layered defines the structures and functions necessary for creating and manipulating layered circuits within the ExpanderCompilerCollection compiler.
Package layered defines the structures and functions necessary for creating and manipulating layered circuits within the ExpanderCompilerCollection compiler.
Package layering provides functionality to compile an IR of a circuit into a layered circuit.
Package layering provides functionality to compile an IR of a circuit into a layered circuit.
Poseidon hash function, written in the layered circuit.
Poseidon hash function, written in the layered circuit.

Jump to

Keyboard shortcuts

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