circuits

package
v0.0.0-...-4e93fa3 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CircuitDigest

func CircuitDigest(circuit constraint.ConstraintSystem) (string, error)

CircuitDigest computes the SHA256 digest of the circuit.

func ProveCheck

func ProveCheck(setup *Setup, assignment frontend.Circuit, opts ...any) (plonk.Proof, error)

Generates a PlonkProof and sanity-checks it against the verifying key. Can take a list of options which can of either backend.ProverOption of backend. VerifierOption.

func ReadVerifyingKey

func ReadVerifyingKey(path string, into plonk.VerifyingKey) error

func SerializeProofRaw

func SerializeProofRaw(proof plonk.Proof) string

Serializes the proof in an 0x prefixed hexstring

func SerializeProofSolidityBn254

func SerializeProofSolidityBn254(proof plonk.Proof) string

Serializes the proof in an 0x prefixed hexstring

Types

type Builder

type Builder interface {
	Compile() (constraint.ConstraintSystem, error)
}

type CircuitID

type CircuitID string

CircuitID is a type to represent the different circuits. It is used to identify the circuit to be used in the prover.

const (
	ExecutionCircuitID                  CircuitID = "execution"
	ExecutionLargeCircuitID             CircuitID = "execution-large"
	BlobDecompressionV0CircuitID        CircuitID = "blob-decompression-v0"
	BlobDecompressionV1CircuitID        CircuitID = "blob-decompression-v1"
	AggregationCircuitID                CircuitID = "aggregation"
	EmulationCircuitID                  CircuitID = "emulation"
	EmulationDummyCircuitID             CircuitID = "emulation-dummy"
	ExecutionDummyCircuitID             CircuitID = "execution-dummy"
	BlobDecompressionDummyCircuitID     CircuitID = "blob-decompression-dummy"
	PublicInputInterconnectionCircuitID CircuitID = "public-input-interconnection"
)

type MockCircuitID

type MockCircuitID int

MockCircuitID is a type to represent the different mock circuits.

const (
	MockCircuitIDExecution     MockCircuitID = 0
	MockCircuitIDDecompression MockCircuitID = 6789
	MockCircuitIDEmulation     MockCircuitID = 1
)

type ProveCheckOption

type ProveCheckOption func(*proveCheckSettings)

func WithCachedProof

func WithCachedProof(path string) ProveCheckOption

type SRSProvider

type SRSProvider interface {
	GetSRS(ctx context.Context, ccs constraint.ConstraintSystem) (kzg.SRS, kzg.SRS, error)
}

type SRSStore

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

func NewSRSStore

func NewSRSStore(rootDir string) (*SRSStore, error)

NewSRSStore creates a new SRSStore

func (*SRSStore) GetSRS

func (store *SRSStore) GetSRS(ctx context.Context, ccs constraint.ConstraintSystem) (kzg.SRS, kzg.SRS, error)

type Setup

type Setup struct {
	Manifest     SetupManifest
	Circuit      constraint.ConstraintSystem
	ProvingKey   plonk.ProvingKey // this is not serialized to disk
	VerifyingKey plonk.VerifyingKey
}

Setup contains the proving and verifying keys of a circuit, as well as the constraint system. It's a common structure used to pass around the resources associated with a circuit.

func LoadSetup

func LoadSetup(cfg *config.Config, circuitID CircuitID) (Setup, error)

func MakeSetup

func MakeSetup(
	ctx context.Context,
	circuitName CircuitID,
	ccs constraint.ConstraintSystem,
	srsProvider SRSProvider,
	extraFlags map[string]any,
) (Setup, error)

MakeSetup returns a setup for a given circuit that is either downloaded from the S3 bucket or generated in an unsafe manner.

func (*Setup) CurveID

func (s *Setup) CurveID() ecc.ID

func (*Setup) VerifyingKeyDigest

func (s *Setup) VerifyingKeyDigest() string

func (*Setup) WriteTo

func (s *Setup) WriteTo(rootDir string) error

WriteTo writes the setup assets to specified root directory.

type SetupManifest

type SetupManifest struct {
	CircuitName string    `json:"circuitName"`
	Timestamp   time.Time `json:"timestamp"`

	// Sha256 of the associated assets
	Checksums struct {
		VerifyingKey     string `json:"verifyingKey"`
		VerifierContract string `json:"verifierContract"`
		Circuit          string `json:"circuit"`
	} `json:"checksums"`

	NbConstraints int            `json:"nbConstraints"`
	CurveID       string         `json:"curveID"`
	ExtraFlags    map[string]any `json:"extraFlags"`
}

SetupManifest is the human-readable manifest of the assets generated by the prover setup command

func NewSetupManifest

func NewSetupManifest(
	circuitName string,
	nbConstraints int,
	curveID ecc.ID,
	extraFlags map[string]any,
) SetupManifest

NewSetupManifest creates a new manifest.

func ReadSetupManifest

func ReadSetupManifest(filePath string) (*SetupManifest, error)

ReadSetupManifestFromFile reads a manifest from a json file

func (*SetupManifest) GetInt

func (m *SetupManifest) GetInt(key string) (int, error)

GetInt returns the value of an int flag set in the ExtraFlags map

func (*SetupManifest) GetString

func (m *SetupManifest) GetString(key string) (string, error)

func (*SetupManifest) GetStringArray

func (m *SetupManifest) GetStringArray(key string) ([]string, error)

func (*SetupManifest) WriteTo

func (m *SetupManifest) WriteTo(filePath string) error

writeToJSONFile writes a manifest to a json file

type UnsafeSRSProvider

type UnsafeSRSProvider struct {
}

func NewUnsafeSRSProvider

func NewUnsafeSRSProvider() UnsafeSRSProvider

NewUnsafeSRSProvider returns a new UnsafeSRSProvider if tau is provided, it will be used as the tau value for the SRS (slow path) otherwise, a random tau will be generated (fast path)

func (UnsafeSRSProvider) GetSRS

Directories

Path Synopsis
The bw6circuit package provides an implementation of the BW6 proof aggregation circuit.
The bw6circuit package provides an implementation of the BW6 proof aggregation circuit.
v0
v1
The bn254 package provides an implementation of a gnark circuit that can recursively verify a PLONK proof on the BW6 field with an arithmetization over the BN254 curve.
The bn254 package provides an implementation of a gnark circuit that can recursively verify a PLONK proof on the BW6 field with an arithmetization over the BN254 curve.

Jump to

Keyboard shortcuts

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