Help us shape the future of Go! Take the 2026 Go Developer Survey

precompiles

package
v1.24.29 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VerifierTypeGroth16 = 0x01
	VerifierTypePLONK   = 0x02
	VerifierTypeSTARK   = 0x03
	VerifierTypeHalo2   = 0x04
	VerifierTypeNova    = 0x05
)

Verifier type identifiers used in cross-chain routing.

View Source
const (
	Groth16VerifierAddr = 0x80
	PLONKVerifierAddr   = 0x81
	STARKVerifierAddr   = 0x82
	Halo2VerifierAddr   = 0x83
	NovaVerifierAddr    = 0x84
)

Precompile addresses for Z-Chain ZK verifiers. These live in the Z-Chain EVM precompile space.

View Source
const CrossChainZKVerifierAddr = 0x0F20

CrossChainZKVerifierAddr is deployed on every EVM chain to route ZK verification requests to Z-Chain via Warp messaging.

Variables

This section is empty.

Functions

func DecodeWarpPayload

func DecodeWarpPayload(data []byte) (zChainID ids.ID, targetAddr byte, payload []byte, err error)

DecodeWarpPayload decodes a cross-chain ZK verification request.

func RegisterZKPrecompiles

func RegisterZKPrecompiles(registry PrecompileRegistry)

RegisterZKPrecompiles registers all Z-Chain ZK verifier precompiles.

Types

type CrossChainZKVerifier

type CrossChainZKVerifier struct {
	ZChainID ids.ID
}

CrossChainZKVerifier routes ZK verification from any EVM chain to Z-Chain.

Input format:

verifier_type (1 byte)
proof_data    (remaining bytes — forwarded to Z-Chain verifier)

The routing works via Warp messaging:

  1. Caller on C-Chain (or any subnet EVM) invokes this precompile
  2. Precompile constructs a Warp message addressed to Z-Chain
  3. Z-Chain receives the message and invokes the appropriate verifier
  4. Result is returned via Warp response

Gas: base 100K (includes Warp relay overhead).

func (*CrossChainZKVerifier) RequiredGas

func (v *CrossChainZKVerifier) RequiredGas(input []byte) uint64

func (*CrossChainZKVerifier) Run

func (v *CrossChainZKVerifier) Run(input []byte) ([]byte, error)

type Groth16Verifier

type Groth16Verifier struct{}

Groth16Verifier verifies Groth16 proofs on Z-Chain using bn254 pairings.

Input format (all points uncompressed):

vk_len     (4 bytes, big-endian)
vk         (vk_len bytes): Alpha(64) | Beta(128) | Gamma(128) | Delta(128) | numK(4) | K[](64*numK)
proof      (256 bytes):    Ar(64) | Bs(128) | Krs(64)
num_inputs (4 bytes, big-endian)
inputs     (32 * num_inputs bytes): field elements

Output: 0x01 if valid, 0x00 if invalid.

func (*Groth16Verifier) RequiredGas

func (v *Groth16Verifier) RequiredGas(input []byte) uint64

func (*Groth16Verifier) Run

func (v *Groth16Verifier) Run(input []byte) ([]byte, error)

type Halo2Verifier

type Halo2Verifier struct{}

Halo2Verifier will verify Halo2 proofs with IPA commitments. Currently returns an error indicating the verifier is not yet available.

func (*Halo2Verifier) RequiredGas

func (v *Halo2Verifier) RequiredGas(input []byte) uint64

func (*Halo2Verifier) Run

func (v *Halo2Verifier) Run(input []byte) ([]byte, error)

type MapRegistry

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

MapRegistry is a simple map-based precompile registry for testing.

func NewMapRegistry

func NewMapRegistry() *MapRegistry

func (*MapRegistry) Get

func (r *MapRegistry) Get(addr byte) (PrecompiledContract, error)

func (*MapRegistry) Register

func (r *MapRegistry) Register(addr byte, contract PrecompiledContract)

type NovaVerifier

type NovaVerifier struct{}

NovaVerifier will verify Nova IVC proofs. Currently returns an error indicating the verifier is not yet available.

func (*NovaVerifier) RequiredGas

func (v *NovaVerifier) RequiredGas(input []byte) uint64

func (*NovaVerifier) Run

func (v *NovaVerifier) Run(input []byte) ([]byte, error)

type PLONKVerifier

type PLONKVerifier struct{}

PLONKVerifier verifies PLONK proofs using KZG polynomial commitments on bn254.

Input format:

vk_len     (4 bytes)
vk         (vk_len bytes)
proof_len  (4 bytes)
proof      (proof_len bytes)
num_inputs (4 bytes)
inputs     (32 * num_inputs bytes)

Output: 0x01 if valid, 0x00 if invalid.

func (*PLONKVerifier) RequiredGas

func (v *PLONKVerifier) RequiredGas(input []byte) uint64

func (*PLONKVerifier) Run

func (v *PLONKVerifier) Run(input []byte) ([]byte, error)

type PrecompileRegistry

type PrecompileRegistry interface {
	Register(addr byte, contract PrecompiledContract)
}

PrecompileRegistry allows registering precompiled contracts at fixed addresses.

type PrecompiledContract

type PrecompiledContract interface {
	RequiredGas(input []byte) uint64
	Run(input []byte) ([]byte, error)
}

PrecompiledContract is the interface that EVM precompiles must satisfy.

type STARKVerifier

type STARKVerifier struct{}

STARKVerifier will verify STARK proofs. Currently returns an error indicating the verifier is not yet available.

func (*STARKVerifier) RequiredGas

func (v *STARKVerifier) RequiredGas(input []byte) uint64

func (*STARKVerifier) Run

func (v *STARKVerifier) Run(input []byte) ([]byte, error)

Jump to

Keyboard shortcuts

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