ecarith

package
v0.0.0-...-35a8ded Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package ecarith provides the integrations of the EC_MUL and EC_ADD precompile calls.

Index

Constants

View Source
const (
	ROUND_NR   = 0
	NAME_ECMUL = "ECMUL_INTEGRATION"
)
View Source
const (
	NAME_ECADD = "ECADD_INTEGRATION"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ECAddInstance

type ECAddInstance struct {
	// First input to addition
	P_X_hi, P_X_lo frontend.Variable `gnark:",public"`
	P_Y_hi, P_Y_lo frontend.Variable `gnark:",public"`

	// Second input to addition
	Q_X_hi, Q_X_lo frontend.Variable `gnark:",public"`
	Q_Y_hi, Q_Y_lo frontend.Variable `gnark:",public"`

	// The result of the addition. Is provided non-deterministically by the
	// caller, we have to ensure that the result is correct.
	R_X_hi, R_X_lo frontend.Variable `gnark:",public"`
	R_Y_hi, R_Y_lo frontend.Variable `gnark:",public"`
}

type ECMulInstance

type ECMulInstance struct {
	P_X_hi, P_X_lo frontend.Variable `gnark:",public"`
	P_Y_hi, P_Y_lo frontend.Variable `gnark:",public"`

	N_hi, N_lo frontend.Variable `gnark:",public"`

	// The result of the multiplication. Is provided by the caller, we have to
	// ensure that the result is correct.
	R_X_hi, R_X_lo frontend.Variable `gnark:",public"`
	R_Y_hi, R_Y_lo frontend.Variable `gnark:",public"`
}

type EcAdd

type EcAdd struct {
	*EcDataAddSource
	AlignedGnarkData *plonk.Alignment

	*Limits
	// contains filtered or unexported fields
}

EcMulIntegration integrated EC_MUL precompile call verification inside a gnark circuit.

func NewEcAddZkEvm

func NewEcAddZkEvm(comp *wizard.CompiledIOP, limits *Limits) *EcAdd

func (*EcAdd) Assign

func (em *EcAdd) Assign(run *wizard.ProverRuntime)

Assign assigns the data from the trace to the gnark inputs.

type EcDataAddSource

type EcDataAddSource struct {
	CsEcAdd ifaces.Column
	Limb    ifaces.Column
	Index   ifaces.Column
	IsData  ifaces.Column
	IsRes   ifaces.Column
}

EcDataAddSource is a struct that holds the columns that are used to fetch data from the EC_DATA module from the arithmetization.

type EcDataMulSource

type EcDataMulSource struct {
	CsEcMul ifaces.Column
	Limb    ifaces.Column
	Index   ifaces.Column
	IsData  ifaces.Column
	IsRes   ifaces.Column
}

EcDataMulSource is a struct that holds the columns that are used to fetch data from the EC_DATA module from the arithmetization.

type EcMul

type EcMul struct {
	*EcDataMulSource
	AlignedGnarkData *plonk.Alignment

	*Limits
	// contains filtered or unexported fields
}

EcMul integrated EC_MUL precompile call verification inside a gnark circuit.

func NewEcMulZkEvm

func NewEcMulZkEvm(comp *wizard.CompiledIOP, limits *Limits) *EcMul

func (*EcMul) Assign

func (em *EcMul) Assign(run *wizard.ProverRuntime)

Assign assigns the data from the trace to the gnark inputs.

type Limits

type Limits struct {
	// how many ecmul can we do in a single circuit
	NbInputInstances int
	// how many circuit instances can we have
	NbCircuitInstances int
}

Limits defines the upper limits on the size of the circuit and the number of gnark circuits. The total number of allowed EC_MUL precompile calls is product of the fields.

type MultiECAddCircuit

type MultiECAddCircuit struct {
	Instances []ECAddInstance
}

MultiECAddCircuit is a circuit that can handle multiple EC_ADD instances. The length of the slice Instances should corresponds to the one defined in the Limits struct.

func NewECAddCircuit

func NewECAddCircuit(limits *Limits) *MultiECAddCircuit

NewECMulCircuit creates a new circuit for verifying the EC_MUL precompile based on the defined number of inputs.

func (*MultiECAddCircuit) Define

func (c *MultiECAddCircuit) Define(api frontend.API) error

type MultiECMulCircuit

type MultiECMulCircuit struct {
	Instances []ECMulInstance
}

MultiECMulCircuit is a circuit that can handle multiple EC_MUL instances. The length of the slice Instances should corresponds to the one defined in the Limits struct.

func NewECMulCircuit

func NewECMulCircuit(limits *Limits) *MultiECMulCircuit

NewECMulCircuit creates a new circuit for verifying the EC_MUL precompile based on the defined number of inputs.

func (*MultiECMulCircuit) Define

func (c *MultiECMulCircuit) Define(api frontend.API) error

Jump to

Keyboard shortcuts

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