gkr

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Gates = map[string]Gate{
	"identity": IdentityGate{},
	"add":      AddGate{},
	"mul":      MulGate{},
}

Functions

func ChallengeNames

func ChallengeNames(sorted []*Wire, logNbInstances int, prefix string) []string

func ProofSize

func ProofSize(c Circuit, logNbInstances int) int

ProofSize computes how large the proof for a circuit would be. It needs nbUniqueOutputs to be set

func ProveHintPlaceholder added in v0.9.0

func ProveHintPlaceholder(*big.Int, []*big.Int, []*big.Int) error

func SolveHintPlaceholder added in v0.9.0

func SolveHintPlaceholder(*big.Int, []*big.Int, []*big.Int) error

func Verify

func Verify(api frontend.API, c Circuit, assignment WireAssignment, proof Proof, transcriptSettings fiatshamir.Settings, options ...Option) error

Verify the consistency of the claimed output with the claimed input Unlike in Prove, the assignment argument need not be complete

Types

type API added in v0.9.0

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

func NewApi added in v0.9.0

func NewApi() *API

NewApi creates a new GKR API

func (*API) Add added in v0.9.0

func (*API) Import added in v0.9.0

func (api *API) Import(assignment []frontend.Variable) (constraint.GkrVariable, error)

Import creates a new input variable, whose values across all instances are given by assignment. If the value in an instance depends on an output of another instance, leave the corresponding index in assigment nil and use Series to specify the dependency.

func (*API) Mul added in v0.9.0

func (*API) NamedGate added in v0.9.0

func (api *API) NamedGate(gate string, in ...constraint.GkrVariable) constraint.GkrVariable

func (*API) Neg added in v0.9.0

func (*API) Println added in v0.9.0

func (api *API) Println(a ...constraint.GkrVariable)

TODO @Tabaie This can be useful

func (*API) Series added in v0.9.0

func (api *API) Series(input, output constraint.GkrVariable, inputInstance, outputInstance int) *API

Series like in an electric circuit, binds an input of an instance to an output of another

func (*API) Solve added in v0.9.0

func (api *API) Solve(parentApi frontend.API) (Solution, error)

Solve finalizes the GKR circuit and returns the output variables in the order created

func (*API) Sub added in v0.9.0

type AddGate

type AddGate struct{}

func (AddGate) Degree

func (a AddGate) Degree() int

func (AddGate) Evaluate

func (a AddGate) Evaluate(api frontend.API, v ...frontend.Variable) frontend.Variable

type Circuit

type Circuit []Wire

type Gate

type Gate interface {
	Evaluate(frontend.API, ...frontend.Variable) frontend.Variable
	Degree() int
}

Gate must be a low-degree polynomial

type IdentityGate

type IdentityGate struct{}

func (IdentityGate) Degree

func (IdentityGate) Degree() int

func (IdentityGate) Evaluate

func (IdentityGate) Evaluate(_ frontend.API, input ...frontend.Variable) frontend.Variable

type MulGate

type MulGate struct{}

func (MulGate) Degree

func (g MulGate) Degree() int

TODO: Degree must take nbInputs as an argument and return degree = nbInputs

func (MulGate) Evaluate

func (g MulGate) Evaluate(api frontend.API, x ...frontend.Variable) frontend.Variable

type Option

type Option func(*settings)

func WithSortedCircuit

func WithSortedCircuit(sorted []*Wire) Option

type Proof

type Proof []sumcheck.Proof // for each layer, for each wire, a sumcheck (for each variable, a polynomial)

func DeserializeProof

func DeserializeProof(sorted []*Wire, serializedProof []frontend.Variable) (Proof, error)

func (Proof) Serialize

func (p Proof) Serialize() []frontend.Variable

type Solution added in v0.9.0

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

func (Solution) Export added in v0.9.0

func (s Solution) Export(v frontend.Variable) []frontend.Variable

Export returns the values of an output variable across all instances

func (Solution) Verify added in v0.9.0

func (s Solution) Verify(hashName string, initialChallenges ...frontend.Variable) error

Verify encodes the verification circuitry for the GKR circuit

type Wire

type Wire struct {
	Gate   Gate
	Inputs []*Wire // if there are no Inputs, the wire is assumed an input wire
	// contains filtered or unexported fields
}

func (Wire) IsInput

func (w Wire) IsInput() bool

func (Wire) IsOutput

func (w Wire) IsOutput() bool

func (Wire) NbClaims

func (w Wire) NbClaims() int

type WireAssignment

type WireAssignment map[*Wire]polynomial.MultiLin

WireAssignment is assignment of values to the same wire across many instances of the circuit

func (WireAssignment) NumInstances

func (a WireAssignment) NumInstances() int

func (WireAssignment) NumVars

func (a WireAssignment) NumVars() int

Jump to

Keyboard shortcuts

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